summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-08-12 11:05:19 +0800
committerPeng Wu <alexepico@gmail.com>2011-08-12 11:05:19 +0800
commit6a1aa9ea5db1822350c78a66e65d4bd344e2d012 (patch)
tree1a1ad38fadfdafada3a6de837ad791e8a77d11bb
parentcc6a9b9b390326fbb504728ddede89a6e6918978 (diff)
downloadlibpinyin-6a1aa9ea5db1822350c78a66e65d4bd344e2d012.tar.gz
libpinyin-6a1aa9ea5db1822350c78a66e65d4bd344e2d012.tar.xz
libpinyin-6a1aa9ea5db1822350c78a66e65d4bd344e2d012.zip
fixes code styles in test directory.
-rw-r--r--tests/include/test_memory_chunk.cpp158
-rw-r--r--tests/storage/test_parser.cpp3
-rw-r--r--tests/storage/test_phrase_index.cpp18
3 files changed, 88 insertions, 91 deletions
diff --git a/tests/include/test_memory_chunk.cpp b/tests/include/test_memory_chunk.cpp
index 14e339b..be83247 100644
--- a/tests/include/test_memory_chunk.cpp
+++ b/tests/include/test_memory_chunk.cpp
@@ -3,85 +3,85 @@
//Test Memory Chunk Functionality
int main(int argc, char * argv[]){
- MemoryChunk* chunk;
- chunk = new MemoryChunk();
- int i = 12;
- chunk->set_content(0, &i, sizeof(int));
-
- int * p = (int *)chunk->begin();
- assert(chunk->size() == sizeof(int));
- printf("%d\n", *p);
- printf("%ld\n", chunk->capacity());
-
- p = & i;
- chunk->set_chunk(p, sizeof(int), NULL);
- short t = 5;
- chunk->set_content(sizeof(int), &t, sizeof(short));
- assert( sizeof(int) + sizeof(short) == chunk->size());
- printf("%ld\n", chunk->capacity());
-
- p = (int *)chunk->begin();
- short * p2 =(short *)(((char *) (chunk->begin())) + sizeof(int));
- printf("%d\t%d\n", *p, *p2);
-
- chunk->set_content(sizeof(int) + sizeof(short), &t, sizeof(short));
+ MemoryChunk* chunk;
+ chunk = new MemoryChunk();
+ int i = 12;
+ chunk->set_content(0, &i, sizeof(int));
+
+ int * p = (int *)chunk->begin();
+ assert(chunk->size() == sizeof(int));
+ printf("%d\n", *p);
+ printf("%ld\n", chunk->capacity());
+
+ p = & i;
+ chunk->set_chunk(p, sizeof(int), NULL);
+ short t = 5;
+ chunk->set_content(sizeof(int), &t, sizeof(short));
+ assert( sizeof(int) + sizeof(short) == chunk->size());
+ printf("%ld\n", chunk->capacity());
+
+ p = (int *)chunk->begin();
+ short * p2 =(short *)(((char *) (chunk->begin())) + sizeof(int));
+ printf("%d\t%d\n", *p, *p2);
+
+ chunk->set_content(sizeof(int) + sizeof(short), &t, sizeof(short));
- assert( sizeof(int) + (sizeof(short) << 1) == chunk->size());
- printf("%ld\n", chunk->capacity());
- p = (int *)chunk->begin();
- p2 =(short *)(((char *) (chunk->begin())) + sizeof(int));
- printf("%d\t%d\t%d\n", *p, *p2, *(p2 + 1));
-
- chunk->set_size(sizeof(int) + sizeof(short) *3);
- p = (int *)chunk->begin();
- p2 =(short *)(((char *) (chunk->begin())) + sizeof(int));
-
- chunk->set_content(0, &i, sizeof(int));
-
- *(p2+2) = 3;
- printf("%d\t%d\t%d\t%d\n", *p, *p2, *(p2 + 1), *(p2+2));
-
- int m = 10;
- chunk->set_chunk(&m, sizeof(int), NULL);
- int n = 12;
- chunk->insert_content(sizeof(int), &n, sizeof(int));
- n = 11;
- chunk->insert_content(sizeof(int), &n, sizeof(int));
-
- int * p3 = (int *)chunk->begin();
- printf("%d\t%d\t%d\n", *p3, *(p3+1), *(p3+2));
+ assert( sizeof(int) + (sizeof(short) << 1) == chunk->size());
+ printf("%ld\n", chunk->capacity());
+ p = (int *)chunk->begin();
+ p2 =(short *)(((char *) (chunk->begin())) + sizeof(int));
+ printf("%d\t%d\t%d\n", *p, *p2, *(p2 + 1));
+
+ chunk->set_size(sizeof(int) + sizeof(short) *3);
+ p = (int *)chunk->begin();
+ p2 =(short *)(((char *) (chunk->begin())) + sizeof(int));
+
+ chunk->set_content(0, &i, sizeof(int));
+
+ *(p2+2) = 3;
+ printf("%d\t%d\t%d\t%d\n", *p, *p2, *(p2 + 1), *(p2+2));
+
+ int m = 10;
+ chunk->set_chunk(&m, sizeof(int), NULL);
+ int n = 12;
+ chunk->insert_content(sizeof(int), &n, sizeof(int));
+ n = 11;
+ chunk->insert_content(sizeof(int), &n, sizeof(int));
+
+ int * p3 = (int *)chunk->begin();
+ printf("%d\t%d\t%d\n", *p3, *(p3+1), *(p3+2));
- chunk->remove_content(sizeof(int), sizeof(int));
- printf("%d\t%d\n", *p3, *(p3+1));
-
- int tmp;
- assert(chunk->get_content(sizeof(int), &tmp, sizeof(int)));
- printf("%d\n", tmp);
-
- //clean up chunk
- delete chunk;
-
- const char * filename = "/tmp/version";
- const char * version = "0.2.0";
-
- //testing version check.
- chunk = new MemoryChunk;
- bool retval = chunk->load(filename);
- if ( !retval ){
- fprintf(stderr, "can't find chunk\n");
- }else if ( memcmp(version, chunk->begin(), strlen(version) + 1) == 0){
- printf("match\n");
- }
-
- chunk->set_content(0, version, strlen(version) + 1);
- chunk->save(filename);
-
- retval = chunk->load(filename);
- if ( !retval ){
- fprintf(stderr, "can't find chunk\n");
- } else if ( memcmp(version, chunk->begin(), strlen(version) + 1) == 0){
- printf("match\n");
- }
-
- return 0;
+ chunk->remove_content(sizeof(int), sizeof(int));
+ printf("%d\t%d\n", *p3, *(p3+1));
+
+ int tmp;
+ assert(chunk->get_content(sizeof(int), &tmp, sizeof(int)));
+ printf("%d\n", tmp);
+
+ //clean up chunk
+ delete chunk;
+
+ const char * filename = "/tmp/version";
+ const char * version = "0.2.0";
+
+ //testing version check.
+ chunk = new MemoryChunk;
+ bool retval = chunk->load(filename);
+ if ( !retval ){
+ fprintf(stderr, "can't find chunk\n");
+ }else if ( memcmp(version, chunk->begin(), strlen(version) + 1) == 0){
+ printf("match\n");
+ }
+
+ chunk->set_content(0, version, strlen(version) + 1);
+ chunk->save(filename);
+
+ retval = chunk->load(filename);
+ if ( !retval ){
+ fprintf(stderr, "can't find chunk\n");
+ } else if ( memcmp(version, chunk->begin(), strlen(version) + 1) == 0){
+ printf("match\n");
+ }
+
+ return 0;
}
diff --git a/tests/storage/test_parser.cpp b/tests/storage/test_parser.cpp
index fe870a3..4a5ebe3 100644
--- a/tests/storage/test_parser.cpp
+++ b/tests/storage/test_parser.cpp
@@ -152,6 +152,3 @@ int main (int argc, char * argv [])
return 0;
}
-/*
-vi:ts=4:nowrap:ai:expandtab
-*/
diff --git a/tests/storage/test_phrase_index.cpp b/tests/storage/test_phrase_index.cpp
index b48d92c..d2d7be9 100644
--- a/tests/storage/test_phrase_index.cpp
+++ b/tests/storage/test_phrase_index.cpp
@@ -75,18 +75,18 @@ int main(int argc, char * argv[]){
print_time(time, bench_times);
{
- PhraseItem item3;
- phrase_index.get_phrase_item(1, item3);
- item3.increase_pinyin_possibility(custom, &key1, 200);
- assert(item3.get_pinyin_possibility(custom, &key1) == 0.5) ;
+ PhraseItem item3;
+ phrase_index.get_phrase_item(1, item3);
+ item3.increase_pinyin_possibility(custom, &key1, 200);
+ assert(item3.get_pinyin_possibility(custom, &key1) == 0.5) ;
}
{
- PhraseItem item5;
- phrase_index.get_phrase_item(1, item5);
- gfloat poss = item5.get_pinyin_possibility(custom, &key1);
- printf("pinyin poss:%f\n", poss);
- assert(poss == 0.5);
+ PhraseItem item5;
+ phrase_index.get_phrase_item(1, item5);
+ gfloat poss = item5.get_pinyin_possibility(custom, &key1);
+ printf("pinyin poss:%f\n", poss);
+ assert(poss == 0.5);
}
FacadePhraseIndex phrase_index_load;