From d05e6aae7096341569eee1e835614b33a3016bd7 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Wed, 24 Oct 2018 12:08:09 +0100 Subject: [PATCH] tests: Convert AddrRangeMap unit test to a GTest Change-Id: Ifeb0b57c0cda77706691286f78325e50edb31c0d Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/13736 Reviewed-by: Jason Lowe-Power Reviewed-by: Giacomo Travaglini --- src/base/SConscript | 1 + .../addr_range_map_test.cc} | 37 ++++++------------- src/unittest/SConscript | 1 - 3 files changed, 13 insertions(+), 26 deletions(-) rename src/{unittest/rangemaptest.cc => base/addr_range_map_test.cc} (81%) diff --git a/src/base/SConscript b/src/base/SConscript index 3570d1574..d84eba14c 100644 --- a/src/base/SConscript +++ b/src/base/SConscript @@ -83,6 +83,7 @@ Source('loader/symtab.cc') Source('stats/text.cc') GTest('addr_range_test', 'addr_range_test.cc') +GTest('AddrRangeMapTest', 'addr_range_map_test.cc') GTest('bituniontest', 'bituniontest.cc') GTest('CircleBufTest', 'circlebuftest.cc') diff --git a/src/unittest/rangemaptest.cc b/src/base/addr_range_map_test.cc similarity index 81% rename from src/unittest/rangemaptest.cc rename to src/base/addr_range_map_test.cc index 88e1c4d66..397372c06 100644 --- a/src/unittest/rangemaptest.cc +++ b/src/base/addr_range_map_test.cc @@ -40,44 +40,31 @@ * Authors: Ali Saidi */ -#include -#include +#include #include "base/addr_range_map.hh" -using namespace std; - -int -main() +// Converted from legacy unit test framework +TEST(AddrRangeMapTest, LegacyTests) { AddrRangeMap r; - AddrRangeMap::const_iterator i; i = r.insert(RangeIn(10, 40), 5); - assert(i != r.end()); - i = r.insert(RangeIn(60, 90), 3); - assert(i != r.end()); + ASSERT_NE(i, r.end()); - i = r.intersects(RangeIn(20, 30)); - assert(i != r.end()); - cout << i->first.to_string() << " " << i->second << endl; - - i = r.contains(RangeIn(55, 55)); - assert(i == r.end()); + i = r.insert(RangeIn(60, 90), 3); + ASSERT_NE(i, r.end()); - i = r.intersects(RangeIn(55, 55)); - assert(i == r.end()); + EXPECT_NE(r.intersects(RangeIn(20, 30)), r.end()); + EXPECT_EQ(r.contains(RangeIn(55, 55)), r.end()); + EXPECT_EQ(r.intersects(RangeIn(55, 55)), r.end()); i = r.insert(RangeIn(0, 12), 1); - assert(i == r.end()); + EXPECT_EQ(i, r.end()); i = r.insert(RangeIn(0, 9), 1); - assert(i != r.end()); - - i = r.contains(RangeIn(20, 30)); - assert(i != r.end()); - cout << i->first.to_string() << " " << i->second << endl; + ASSERT_NE(i, r.end()); - return 0; + EXPECT_NE(r.contains(RangeIn(20, 30)), r.end()); } diff --git a/src/unittest/SConscript b/src/unittest/SConscript index b104932ba..3f657345f 100644 --- a/src/unittest/SConscript +++ b/src/unittest/SConscript @@ -35,7 +35,6 @@ Source('unittest.cc') UnitTest('cprintftime', 'cprintftime.cc') UnitTest('initest', 'initest.cc') UnitTest('nmtest', 'nmtest.cc') -UnitTest('rangemaptest', 'rangemaptest.cc') UnitTest('refcnttest', 'refcnttest.cc') UnitTest('strnumtest', 'strnumtest.cc') -- 2.30.2