test(set): add set of pointers test
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
b1b49e86e7
commit
42edc4a72d
2 changed files with 37 additions and 0 deletions
|
@ -58,3 +58,6 @@ add_test(hash ${CMAKE_CURRENT_BINARY_DIR}/hash)
|
||||||
add_executable(safe_arith safe_arith.cpp)
|
add_executable(safe_arith safe_arith.cpp)
|
||||||
target_link_libraries(safe_arith ${EXTRA_LIBS})
|
target_link_libraries(safe_arith ${EXTRA_LIBS})
|
||||||
add_test(safe_arith ${CMAKE_CURRENT_BINARY_DIR}/safe_arith)
|
add_test(safe_arith ${CMAKE_CURRENT_BINARY_DIR}/safe_arith)
|
||||||
|
add_executable(set set.cpp)
|
||||||
|
target_link_libraries(set ${EXTRA_LIBS})
|
||||||
|
add_test(set ${CMAKE_CURRENT_BINARY_DIR}/set)
|
||||||
|
|
34
src/tests/util/set.cpp
Normal file
34
src/tests/util/set.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
||||||
|
Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
|
||||||
|
Author: Leonardo de Moura
|
||||||
|
*/
|
||||||
|
#include <set>
|
||||||
|
#include "util/test.h"
|
||||||
|
using namespace lean;
|
||||||
|
|
||||||
|
static void tst1() {
|
||||||
|
std::set<int*> s;
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int c;
|
||||||
|
a = 10;
|
||||||
|
b = 20;
|
||||||
|
c = 5;
|
||||||
|
s.insert(&a);
|
||||||
|
s.insert(&b);
|
||||||
|
lean_assert(s.size() == 2);
|
||||||
|
s.insert(&a);
|
||||||
|
lean_assert(s.size() == 2);
|
||||||
|
s.insert(&c);
|
||||||
|
lean_assert(s.size() == 3);
|
||||||
|
for (int * v : s) {
|
||||||
|
std::cout << *v << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
tst1();
|
||||||
|
return has_violations() ? 1 : 0;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue