Changeset 1838


Ignore:
Timestamp:
Jan 7, 2012, 6:15:25 PM (7 years ago)
Author:
ksherdy
Message:

Added general case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/test/byte_compare_generator.cpp

    r1831 r1838  
    1 #include "../byte_compare.hpp"
     1#include "byte_compare.hpp"
    22#include <stdint.h>
    33#include <iostream>
     
    7777
    7878
    79 string gen_overlap_compare_test(string type, int lgth, string x, int idx_x, string y, int idx_y) {
     79string gen_overlap_compare_call_T_L(string type, int lgth, string x, int idx_x, string y, int idx_y) {
    8080
    8181    ostringstream ostr;
     
    9292}
    9393
     94string gen_overlap_compare_call_T(string type, int lgth, string x, int idx_x, string y, int idx_y) {
     95
     96    ostringstream ostr;
     97    ostr << "cout << \""
     98         << "x=\\\"\" << " << x << "[" << idx_x << "]" << "<< \"\\\""
     99         << " y=\\\"\" << " << y << "[" << idx_y << "]" << "<< \"\\\""
     100         << " L=" << lgth << " "
     101         << " R=\" << overlap_compare<" << type << "," << ">(" << "(" << type << "*)&"
     102         << x << "[" << idx_x << "]"<< ",(" << type << "*)&"
     103         << y << "[" << idx_y << "] ,"
     104         << lgth << ")"
     105         << " << endl;" <<endl;
     106
     107    return ostr.str();
     108}
    94109
    95110int main() {
     
    106121    buffer << "cout << \"overlap_compare<uint8_t,i>(x,y)\" << endl;" << endl;
    107122    for(int i=sizeof(uint8_t);i<=size;i++) {
    108         buffer << gen_overlap_compare_test("uint8_t", i, x, i, x, i);
     123        buffer << gen_overlap_compare_call_T_L("uint8_t", i, x, i, x, i);
    109124    }
    110125
    111126    for(int i=sizeof(uint8_t);i<=size;i++) {
    112         buffer << gen_overlap_compare_test("uint8_t", i, x, i, y, i);
     127        buffer << gen_overlap_compare_call_T_L("uint8_t", i, x, i, y, i);
    113128    }
    114129
    115130    buffer << "cout << \"overlap_compare<uint16_t,i>(x,y)\" << endl;" << endl;
    116131    for(int i=sizeof(uint16_t);i<=size;i++) {
    117         buffer << gen_overlap_compare_test("uint16_t", i, x, i, x, i);
     132        buffer << gen_overlap_compare_call_T_L("uint16_t", i, x, i, x, i);
    118133    }
    119134
    120135    for(int i=sizeof(uint16_t);i<=size;i++) {
    121         buffer << gen_overlap_compare_test("uint16_t", i, x, i, y, i);
     136        buffer << gen_overlap_compare_call_T_L("uint16_t", i, x, i, y, i);
    122137    }
    123138
    124139    buffer << "cout << \"overlap_compare<uint32_t,i>(x,y)\" << endl;" << endl;
    125140    for(int i=sizeof(uint32_t);i<=size;i++) {
    126         buffer << gen_overlap_compare_test("uint32_t", i, x, i, x, i);
     141        buffer << gen_overlap_compare_call_T_L("uint32_t", i, x, i, x, i);
    127142    }
    128143
    129144    for(int i=sizeof(uint32_t);i<=size;i++) {
    130         buffer << gen_overlap_compare_test("uint32_t", i, x, i, y, i);
     145        buffer << gen_overlap_compare_call_T_L("uint32_t", i, x, i, y, i);
    131146    }
    132147
    133148    buffer << "cout << \"overlap_compare<uint64_t,i>(x,y)\" << endl;" << endl;
    134149    for(int i=sizeof(uint64_t);i<=size;i++) {
    135         buffer << gen_overlap_compare_test("uint64_t", i, x, i, x, i);
     150        buffer << gen_overlap_compare_call_T_L("uint64_t", i, x, i, x, i);
    136151    }
    137152
    138153    for(int i=sizeof(uint64_t);i<=size;i++) {
    139         buffer << gen_overlap_compare_test("uint64_t", i, x, i, y, i);
     154        buffer << gen_overlap_compare_call_T_L("uint64_t", i, x, i, y, i);
    140155    }
    141156
    142157    buffer << "cout << \"overlap_compare<BitBlock,i>(x,y)\" << endl;" << endl;
    143158    for(int i=sizeof(BitBlock);i<=size;i++) {
    144         buffer << gen_overlap_compare_test("BitBlock", i, x, i, x, i);
     159        buffer << gen_overlap_compare_call_T_L("BitBlock", i, x, i, x, i);
    145160    }
    146161
    147162    for(int i=sizeof(BitBlock);i<=size;i++) {
    148         buffer << gen_overlap_compare_test("BitBlock", i, x, i, y, i);
     163        buffer << gen_overlap_compare_call_T_L("BitBlock", i, x, i, y, i);
    149164    }
     165
     166    buffer << "cout << \"overlap_compare<BitBlock>(x,y,lgth)\" << endl;" << endl;
     167    for(int i=sizeof(BitBlock);i<=size;i++) {
     168        buffer << gen_overlap_compare_call_T("BitBlock", i, x, i, x, i);
     169    }
     170
     171    for(int i=sizeof(BitBlock);i<=size;i++) {
     172        buffer << gen_overlap_compare_call_T("BitBlock", i, x, i, y, i);
     173    }
     174
    150175    string test_cases = buffer.str();
    151176
Note: See TracChangeset for help on using the changeset viewer.