summaryrefslogtreecommitdiffstats
path: root/amend/test_symtab.c
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2009-07-16 03:10:28 +0200
committerDoug Zongker <dougz@android.com>2009-07-16 03:10:28 +0200
commit608fa02e1ac0ea11a0d3ca754f38bd76b77faa82 (patch)
tree5e7eb02fce9e783a2a149b8580e3da69d3cb6a2d /amend/test_symtab.c
parentam bec02d57: skip over all-zero blocks when reading MTD partition (diff)
parentremove amend (diff)
downloadandroid_bootable_recovery-608fa02e1ac0ea11a0d3ca754f38bd76b77faa82.tar
android_bootable_recovery-608fa02e1ac0ea11a0d3ca754f38bd76b77faa82.tar.gz
android_bootable_recovery-608fa02e1ac0ea11a0d3ca754f38bd76b77faa82.tar.bz2
android_bootable_recovery-608fa02e1ac0ea11a0d3ca754f38bd76b77faa82.tar.lz
android_bootable_recovery-608fa02e1ac0ea11a0d3ca754f38bd76b77faa82.tar.xz
android_bootable_recovery-608fa02e1ac0ea11a0d3ca754f38bd76b77faa82.tar.zst
android_bootable_recovery-608fa02e1ac0ea11a0d3ca754f38bd76b77faa82.zip
Diffstat (limited to 'amend/test_symtab.c')
-rw-r--r--amend/test_symtab.c146
1 files changed, 0 insertions, 146 deletions
diff --git a/amend/test_symtab.c b/amend/test_symtab.c
deleted file mode 100644
index 017d18ccd..000000000
--- a/amend/test_symtab.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#undef NDEBUG
-#include <assert.h>
-#include "symtab.h"
-
-int
-test_symtab()
-{
- SymbolTable *tab;
- void *cookie;
- int ret;
-
- /* Test creation */
- tab = createSymbolTable();
- assert(tab != NULL);
-
- /* Smoke-test deletion */
- deleteSymbolTable(tab);
-
-
- tab = createSymbolTable();
- assert(tab != NULL);
-
-
- /* table parameter must be non-NULL. */
- ret = addToSymbolTable(NULL, NULL, 0, NULL);
- assert(ret < 0);
-
- /* symbol parameter must be non-NULL. */
- ret = addToSymbolTable(tab, NULL, 0, NULL);
- assert(ret < 0);
-
- /* cookie parameter must be non-NULL. */
- ret = addToSymbolTable(tab, "null", 0, NULL);
- assert(ret < 0);
-
-
- /* table parameter must be non-NULL. */
- cookie = findInSymbolTable(NULL, NULL, 0);
- assert(cookie == NULL);
-
- /* symbol parameter must be non-NULL. */
- cookie = findInSymbolTable(tab, NULL, 0);
- assert(cookie == NULL);
-
-
- /* Try some actual inserts.
- */
- ret = addToSymbolTable(tab, "one", 0, (void *)1);
- assert(ret == 0);
-
- ret = addToSymbolTable(tab, "two", 0, (void *)2);
- assert(ret == 0);
-
- ret = addToSymbolTable(tab, "three", 0, (void *)3);
- assert(ret == 0);
-
- /* Try some lookups.
- */
- cookie = findInSymbolTable(tab, "one", 0);
- assert((int)cookie == 1);
-
- cookie = findInSymbolTable(tab, "two", 0);
- assert((int)cookie == 2);
-
- cookie = findInSymbolTable(tab, "three", 0);
- assert((int)cookie == 3);
-
- /* Try to insert something that's already there.
- */
- ret = addToSymbolTable(tab, "one", 0, (void *)1111);
- assert(ret < 0);
-
- /* Make sure that the failed duplicate insert didn't
- * clobber the original cookie value.
- */
- cookie = findInSymbolTable(tab, "one", 0);
- assert((int)cookie == 1);
-
- /* Try looking up something that isn't there.
- */
- cookie = findInSymbolTable(tab, "FOUR", 0);
- assert(cookie == NULL);
-
- /* Try looking up something that's similar to an existing entry.
- */
- cookie = findInSymbolTable(tab, "on", 0);
- assert(cookie == NULL);
-
- cookie = findInSymbolTable(tab, "onee", 0);
- assert(cookie == NULL);
-
- /* Test flags.
- * Try inserting something with a different flag.
- */
- ret = addToSymbolTable(tab, "ten", 333, (void *)10);
- assert(ret == 0);
-
- /* Make sure it's there.
- */
- cookie = findInSymbolTable(tab, "ten", 333);
- assert((int)cookie == 10);
-
- /* Make sure it's not there when looked up with a different flag.
- */
- cookie = findInSymbolTable(tab, "ten", 0);
- assert(cookie == NULL);
-
- /* Try inserting something that has the same name as something
- * with a different flag.
- */
- ret = addToSymbolTable(tab, "one", 333, (void *)11);
- assert(ret == 0);
-
- /* Make sure the new entry exists.
- */
- cookie = findInSymbolTable(tab, "one", 333);
- assert((int)cookie == 11);
-
- /* Make sure the old entry still has the right value.
- */
- cookie = findInSymbolTable(tab, "one", 0);
- assert((int)cookie == 1);
-
- /* Try deleting again, now that there's stuff in the table.
- */
- deleteSymbolTable(tab);
-
- return 0;
-}