-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated test code from BSTDictionary
Signed-off-by: unknown <saq10002@iteb-219.ad.engr.uconn.edu>
- Loading branch information
saq10002
committed
Oct 11, 2014
1 parent
2f0577d
commit d5dfb24
Showing
5 changed files
with
104 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
|
||
#if YASI_TEST_THIS_MODULE != 1 | ||
#define YASI_TEST_THIS_MODULE 1 | ||
#endif | ||
#include "ds.BSTdictionary.h" | ||
|
||
namespace yasi{ | ||
namespace ds{ | ||
class BSTDictionaryTest : public yasi::Test{ | ||
typedef BSTDictionary<int> Dict; | ||
public: | ||
void all(){ | ||
Dict d; | ||
ASSERT_EQ(0, d.size()) << "size not 0"; | ||
ASSERT_EQ(true, d.empty()) << "d not empty"; | ||
|
||
for (int i = 0; i < 20; i += 5){ | ||
// keys: 0, 5, 10, 15 | ||
// values: 0, 50, 100, 150 | ||
d.insert(i, i * 10); | ||
} | ||
ASSERT_EQ(4, d.size()) << "size not 4"; | ||
ASSERT_EQ(false, d.empty()) << "d empty"; | ||
|
||
// insert an already-existing item; should update current value | ||
d.insert(5, 500); | ||
ASSERT_EQ(4, d.size()) << "size changed by re-insertion"; | ||
ASSERT_EQ(500, *d.find(5)) << "value not updated by re-insertion"; | ||
|
||
/// try to find non-existent items | ||
ASSERT_EQ(0, (int)d.find(3)) << "non-null ptr for non-existent key"; | ||
// try to find existent items | ||
ASSERT_EQ(500, *d.find(5)) << "value at 5 not 500"; | ||
ASSERT_EQ(150, *d.find(15)) << "value at 15 not 150"; | ||
|
||
// remove some items | ||
d.remove(5); | ||
d.remove(15); | ||
ASSERT_EQ(2, d.size()) << "size not 2"; | ||
|
||
/// try to find non-existent items | ||
ASSERT_EQ(0, (int)d.find(3)) << "non-null ptr for non-existent key 3"; | ||
ASSERT_EQ(0, (int)d.find(5)) << "non-null ptr for non-existent key 5"; | ||
ASSERT_EQ(0, (int)d.find(15)) << "non-null ptr for non-existent key 15"; | ||
// try to find existent items | ||
ASSERT_EQ(0, *d.find(0)) << "value at 0 not 50"; | ||
ASSERT_EQ(100, *d.find(10)) << "value at 10 not 100"; | ||
|
||
// clear | ||
d.clear(); | ||
ASSERT_EQ(0, d.size()) << "size not 0"; | ||
ASSERT_EQ(true, d.empty()) << "d not empty"; | ||
|
||
|
||
} | ||
|
||
}; | ||
|
||
ADD_TEST_F(BSTDictionaryTest, all); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters