Changeset 2012


Ignore:
Timestamp:
Apr 9, 2012, 11:51:31 PM (7 years ago)
Author:
ksherdy
Message:

Added test cases for Forward and Reverse scanners.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtest/bitscantest.cpp

    r1891 r2012  
    11#include "../lib/idisa.hpp"
    22#include "../lib/bitblock.hpp"
     3#include "../lib/bitblock_scan.hpp"
    34#include <iostream>
    45using namespace std;
     
    1112        for (int i = 1; i < sizeof(BitBlock)*8; i++) {
    1213                t = bitblock::slli<1>(t);
     14
    1315                int count_f = count_forward_zeroes(t);
    1416                int count_b = count_reverse_zeroes(t);
     
    2224                }
    2325        }
     26
     27        t = simd<128>::constant<1>();
     28
     29        for (int i = 1; i < sizeof(BitBlock)*8; i++) {
     30                t = bitblock::slli<1>(t);
     31
     32                ForwardScanner<BitBlock, scanword_t> f(&t);
     33                ReverseScanner<BitBlock, scanword_t> r(&t);
     34
     35                f.scan_to_next();               
     36                if (f.get_pos() != i) {
     37                        failed_tests++;
     38                        cout << "Test failure: count_forward_zeroes(bitblock::sll(one, " << i << ") == " << f.get_pos() << endl;
     39                }
     40
     41                r.scan_to_next();
     42                if (r.get_pos() != i) {
     43                        failed_tests++;
     44                        cout << "Test failure: count_reverse_zeroes(bitblock::sll(one, " << i << ") == " << r.get_pos() << endl;
     45                }
     46        }
     47
    2448        if (failed_tests == 0) cout << "All tests succeeded." << endl;
    2549
    2650}
    2751
     52
Note: See TracChangeset for help on using the changeset viewer.