From 069301a603ad07338179bafed0c35b6fe3b372f2 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Thu, 22 Jan 2026 02:24:44 +0100 Subject: Better arg parsing --- tests.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) mode change 100644 => 100755 tests.sh (limited to 'tests.sh') diff --git a/tests.sh b/tests.sh old mode 100644 new mode 100755 index 6f3d7f1..f191e87 --- a/tests.sh +++ b/tests.sh @@ -29,6 +29,26 @@ run_test() { fi } +run_test_with_flags() { + local label=$1 + local flags=$2 + local search_term=$3 + local file=$4 + local expected_pattern=$5 + + printf "Testing %-50s " "$label ($flags $search_term)" + output=$($CREP $flags "$search_term" "$file") + + if echo "$output" | grep -q "$expected_pattern"; then + echo "PASSED" + else + echo "FAILED" + echo " Expected pattern: $expected_pattern" + echo " Actual output: $output" + failed=$((failed + 1)) + fi +} + echo "Starting tests..." echo "----------------" @@ -77,6 +97,14 @@ run_test "C++ Class" "MyClass" "$TEST_DIR/test.cpp" "class MyClass" run_test "C++ Struct" "MyStruct" "$TEST_DIR/test.cpp" "struct MyStruct" run_test "C++ Method" "myMethod" "$TEST_DIR/test.cpp" "void myMethod ()" +# Case Sensitivity Tests +run_test "Default Case Insensitive" "foo" "tests/test.c" "void FooBar" +run_test_with_flags "Case Sensitive -c" "-c" "foobar" "tests/test.c" "void foobar" + +# Depth Tests +run_test_with_flags "Depth 0 (root)" "-d 0" "level" "tests/depth_test" "void level0" +run_test_with_flags "Depth 1 (recursive)" "-d 1" "level" "tests/depth_test" "void level1" + echo "----------------" if [ $failed -eq 0 ]; then echo "All tests passed!" -- cgit v1.2.3