From 7a3fd268e11a690be36d9538d1951237e3677424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 22 Dec 2008 18:05:22 +0000 Subject: [PATCH] TestTokenizer : Broke up TestTokenizer::ifAddBraces into a few separate tests --- testtokenize.cpp | 96 ++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/testtokenize.cpp b/testtokenize.cpp index a486bc6fc..38cb3d0e8 100644 --- a/testtokenize.cpp +++ b/testtokenize.cpp @@ -46,7 +46,9 @@ private: TEST_CASE( const_and_volatile_functions ); - TEST_CASE( ifAddBraces ); + TEST_CASE( ifAddBraces1 ); + TEST_CASE( ifAddBraces2 ); + TEST_CASE( ifAddBraces3 ); TEST_CASE( numeric_true_condition ); @@ -222,64 +224,64 @@ private: ASSERT_EQUALS( std::string(" void f ( ) { ; }"), ostr.str() ); } - void ifAddBraces() + void ifAddBraces1() { - { - const char code[] = "void f()\n" - "{\n" - " if (a);\n" - "}\n"; + const char code[] = "void f()\n" + "{\n" + " if (a);\n" + "}\n"; - // tokenize.. - Tokenizer tokenizer; - std::istringstream istr(code); - tokenizer.tokenize(istr, "test.cpp"); + // tokenize.. + Tokenizer tokenizer; + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); - ASSERT_EQUALS( true, tokenizer.simplifyIfAddBraces() ); + ASSERT_EQUALS( true, tokenizer.simplifyIfAddBraces() ); - std::ostringstream ostr; - for (const TOKEN *tok = tokenizer.tokens(); tok; tok = tok->next()) - ostr << " " << tok->str(); - ASSERT_EQUALS( std::string(" void f ( ) { if ( a ) { ; } }"), ostr.str() ); - } + std::ostringstream ostr; + for (const TOKEN *tok = tokenizer.tokens(); tok; tok = tok->next()) + ostr << " " << tok->str(); + ASSERT_EQUALS( std::string(" void f ( ) { if ( a ) { ; } }"), ostr.str() ); + } - { - const char code[] = "void f()\n" - "{\n" - " if (a) if (b) { }\n" - "}\n"; + void ifAddBraces2() + { + const char code[] = "void f()\n" + "{\n" + " if (a) if (b) { }\n" + "}\n"; - // tokenize.. - Tokenizer tokenizer; - std::istringstream istr(code); - tokenizer.tokenize(istr, "test.cpp"); + // tokenize.. + Tokenizer tokenizer; + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); - ASSERT_EQUALS( true, tokenizer.simplifyIfAddBraces() ); + ASSERT_EQUALS( true, tokenizer.simplifyIfAddBraces() ); - std::ostringstream ostr; - for (const TOKEN *tok = tokenizer.tokens(); tok; tok = tok->next()) - ostr << " " << tok->str(); - ASSERT_EQUALS( std::string(" void f ( ) { if ( a ) { if ( b ) { } } }"), ostr.str() ); - } + std::ostringstream ostr; + for (const TOKEN *tok = tokenizer.tokens(); tok; tok = tok->next()) + ostr << " " << tok->str(); + ASSERT_EQUALS( std::string(" void f ( ) { if ( a ) { if ( b ) { } } }"), ostr.str() ); + } - { - const char code[] = "void f()\n" - "{\n" - " if (a) for (;;) { }\n" - "}\n"; + void ifAddBraces3() + { + const char code[] = "void f()\n" + "{\n" + " if (a) for (;;) { }\n" + "}\n"; - // tokenize.. - Tokenizer tokenizer; - std::istringstream istr(code); - tokenizer.tokenize(istr, "test.cpp"); + // tokenize.. + Tokenizer tokenizer; + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); - ASSERT_EQUALS( true, tokenizer.simplifyIfAddBraces() ); + ASSERT_EQUALS( true, tokenizer.simplifyIfAddBraces() ); - std::ostringstream ostr; - for (const TOKEN *tok = tokenizer.tokens(); tok; tok = tok->next()) - ostr << " " << tok->str(); - ASSERT_EQUALS( std::string(" void f ( ) { if ( a ) { for ( ; ; ) { } } }"), ostr.str() ); - } + std::ostringstream ostr; + for (const TOKEN *tok = tokenizer.tokens(); tok; tok = tok->next()) + ostr << " " << tok->str(); + ASSERT_EQUALS( std::string(" void f ( ) { if ( a ) { for ( ; ; ) { } } }"), ostr.str() ); } void simplify_known_variables()