ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/gtest.cpp
(Generate patch)
# Line 1 | Line 1
1   #include "GBase.h"
2   #include "GArgs.h"
3   #include "GStr.h"
4 + #include "GBitVec.h"
5  
6   #define USAGE "Usage:\n\
7 < gtest [-g|--genomic-fasta <genomic_seqs_fasta>] [-c|COV=<cov%>] \n\
7 > gtest [--bit-test|-g|--genomic-fasta <genomic_seqs_fasta>] [-c|COV=<cov%>] \n\
8   [-s|--seq <seq_info.fsize>] [-o|--out <outfile.gff>] [--disable-flag] [-t|--test <string>]\n\
9   [-p|PID=<pid%>] file1 [file2 file3 ..]\n\
10   "
# Line 16 | Line 17
17   OPT_DISABLE_FLAG,
18   OPT_TEST,
19   OPT_PID,
20 + OPT_BITVEC
21   };
22  
23   GArgsDef opts[] = {
# Line 27 | Line 29
29   {"disable-flag",   0,  0, OPT_DISABLE_FLAG},
30   {"test",          't', 1, OPT_TEST},
31   {"PID",           'p', 1, OPT_PID},
32 + {"bit-test",      'B', 0, OPT_BITVEC},
33   {0,0,0,0}
34   };
35  
36 + void bitError(int idx) {
37 + GError("Error bit checking (index %d)!\n", idx);
38 + }
39 +
40 +
41   int main(int argc, char * const argv[]) {
42   //GArgs args(argc, argv, "hg:c:s:t:o:p:help;genomic-fasta=COV=PID=seq=out=disable-flag;test=");
43   GArgs args(argc, argv, opts);
# Line 58 | Line 66
66       GMessage("%s\n",a);
67       }
68     }
69 + GStr s=args.getOpt('t');
70 + if (!s.is_empty()) {
71 +    GStr token;
72 +    GMessage("Tokens in \"%s\" :\n",s.chars());
73 +    s.startTokenize(";,: \t");
74 +    int c=1;
75 +    while (s.nextToken(token)) {
76 +      GMessage("token %2d : \"%s\"\n",c,token.chars());
77 +      c++;
78 +      }
79 +    }
80 + if (args.getOpt(OPT_BITVEC)) {
81 +    GBitVec bits(2044);
82 +    GMessage(">>> -- Start BitVec Test -- \n");
83 +    if (bits[1092]) bitError(1092);
84 +    bits.resize(2049);
85 +    if (bits[2048]) bitError(2048);
86 +    bits[2048]=true;
87 +    if (!bits[2048]) bitError(2048);
88 +    bits.resize(4097);
89 +    if (!bits[2048]) bitError(2048);
90 +    if (bits[4096]) bitError(4096);
91 +    bits[4096]=true;
92 +    if (!bits[4096]) bitError(4096);
93 +    GBitVec bits2(64);
94 +    Gswap(bits, bits2);
95 +    if (!bits2[2048]) bitError(2048);
96 +    if (!bits2[4096]) bitError(4096);
97 +    
98 +    GMessage("<<< -- End BitVec Test (size: %d, count: %d, bits2 size=%d, count=%d) --\n",
99 +           bits.size(), bits.count(), bits2.size(), bits2.count());
100 +    }
101   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines