Add test cases for format

This commit is contained in:
Soonho Kong 2013-07-23 16:20:44 -07:00
parent 03b1ce643e
commit ab81a57d86
2 changed files with 48 additions and 0 deletions

View file

@ -4,3 +4,6 @@ add_test(interrupt ${CMAKE_CURRENT_BINARY_DIR}/interrupt)
add_executable(name name.cpp) add_executable(name name.cpp)
target_link_libraries(name ${EXTRA_LIBS}) target_link_libraries(name ${EXTRA_LIBS})
add_test(name ${CMAKE_CURRENT_BINARY_DIR}/name) add_test(name ${CMAKE_CURRENT_BINARY_DIR}/name)
add_executable(format format.cpp)
target_link_libraries(format ${EXTRA_LIBS})
add_test(format ${CMAKE_CURRENT_BINARY_DIR}/format)

45
src/tests/util/format.cpp Normal file
View file

@ -0,0 +1,45 @@
/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Soonho Kong
*/
#include "format.h"
#include "test.h"
using namespace lean;
static void tst1() {
format f_atom1("foo");
format f_atom2("bar");
format f_atom3(1);
format f_atom4(3.1415);
format f1(f_atom1, f_atom2);
format f2(f1);
format f3 = choice(f1, f2);
format f4 = nest(3, f3);
format f5 = line();
format f6(f4, f5);
format f7(f6, f3);
std::cout << "f_atom1 = " << f_atom1 << std::endl
<< "f_atom2 = " << f_atom2 << std::endl
<< "f_atom3 = " << f_atom3 << std::endl
<< "f_atom4 = " << f_atom4 << std::endl
;
std::cout << "f1 = " << f1 << std::endl
<< "f2 = " << f2 << std::endl
<< "f3 = " << f3 << std::endl
<< "f4 = " << f4 << std::endl
<< "f5 = " << f5 << std::endl
<< "f6 = " << f6 << std::endl
<< "f7 = " << f7 << std::endl
;
}
int main() {
continue_on_violation(true);
tst1();
return has_violations() ? 1 : 0;
}