Skip to content

Commit 681e123

Browse files
committed
Code cleanup.
1 parent 14759ac commit 681e123

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

test/TestWildcard.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include "TestWildcard.h"
2626
#include "Wildcard.h"
27+
#include <sstream>
28+
2729
namespace shellanything { namespace test
2830
{
2931
std::string WildcardRebuild(const char * pattern, const WildcardList & matches)
@@ -49,6 +51,15 @@ namespace shellanything { namespace test
4951

5052
return output;
5153
}
54+
55+
std::string toString(size_t i)
56+
{
57+
std::stringstream out;
58+
out << i;
59+
const std::string & s = out.str();
60+
return s;
61+
}
62+
5263
//--------------------------------------------------------------------------------------------------
5364
void TestWildcard::SetUp()
5465
{
@@ -149,6 +160,58 @@ namespace shellanything { namespace test
149160
//--------------------------------------------------------------------------------------------------
150161
TEST_F(TestWildcard, testBasic)
151162
{
163+
/*
164+
struct TEST
165+
{
166+
const char * pattern;
167+
const char * value;
168+
bool expected_result;
169+
};
170+
171+
static const TEST tests[] = {
172+
{"","a",true},
173+
};
174+
static const size_t num_tests = sizeof(tests)/sizeof(tests[0]);
175+
176+
// For each tests
177+
for(size_t i=0; i<num_tests; i++)
178+
{
179+
const TEST & test = tests[i];
180+
181+
//Build an custom error message
182+
std::string msg;
183+
msg += "Unexpected assertion: ";
184+
msg += "i=" + toString(i) + ", ";
185+
msg += "pattern \"" + std::string(test.pattern) + "\" and ";
186+
msg += "value \"" + std::string(test.value) + "\" ";
187+
if (test.expected_result)
188+
msg += "should be matching.";
189+
else
190+
msg += "should NOT be matching.";
191+
192+
// Test WildcardSolve()
193+
WildcardList matches;
194+
bool success = WildcardSolve(test.pattern, test.value, matches);
195+
if (test.expected_result)
196+
{
197+
ASSERT_TRUE( success ) << msg;
198+
199+
// Try rebuilding the value from the pattern and the matches
200+
std::string rebuild = WildcardRebuild(test.pattern, matches);
201+
ASSERT_EQ( rebuild, test.value ) << msg;
202+
}
203+
else
204+
ASSERT_FALSE( success ) << msg;
205+
206+
// Test WildcardMatch() as well.
207+
success = WildcardMatch(test.pattern, test.value);
208+
if (test.expected_result)
209+
ASSERT_TRUE( success ) << msg;
210+
else
211+
ASSERT_FALSE( success ) << msg;
212+
}
213+
*/
214+
152215
// Test no wildcard characters
153216
{
154217
WildcardList matches;

0 commit comments

Comments
 (0)