source: trunk/libtest/bitscantest.cpp @ 1899

Last change on this file since 1899 was 1891, checked in by cameron, 7 years ago

Bitscan test routine.

File size: 762 bytes
Line 
1#include "../lib/idisa.hpp"
2#include "../lib/bitblock.hpp"
3#include <iostream>
4using namespace std;
5
6int main() {
7        int failed_tests = 0;
8
9        BitBlock t = simd<128>::constant<1>();
10       
11        for (int i = 1; i < sizeof(BitBlock)*8; i++) {
12                t = bitblock::slli<1>(t);
13                int count_f = count_forward_zeroes(t);
14                int count_b = count_reverse_zeroes(t);
15                if (count_forward_zeroes(t) != i) {
16                        failed_tests++;
17                        cout << "Test failure: count_forward_zeroes(bitblock::sll(one, " << i << ") == " << count_f << endl;
18                }
19                if (count_reverse_zeroes(t) != (sizeof(BitBlock)*8-i-1)) {
20                        failed_tests++;
21                        cout << "Test failure: count_reverse_zeroes(bitblock::sll(one, " << i << ") == " << count_b << endl;
22                }
23        }
24        if (failed_tests == 0) cout << "All tests succeeded." << endl;
25
26}
27
Note: See TracBrowser for help on using the repository browser.