-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.sh
More file actions
93 lines (59 loc) · 1.33 KB
/
Copy pathtest.sh
File metadata and controls
93 lines (59 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
echo "Running unit tests..."
PASS=0
FAIL=0
# Test 1: RMS of a known array
test_rms() {
gcc -o test_rms test_rms.c PSolver.c -lm
./test_rms > tmp.out
result=$(cat tmp.out)
expected="1.000000"
if [[ "$result" == "$expected" ]]; then
echo "test_rms passed"
((PASS++))
else
echo "test_rms failed: expected $expected, got $result"
((FAIL++))
fi
rm -f test_rms tmp.out
}
# Test 2: Dirichlet BC
test_bc() {
gcc -o test_bc test_bc.c PSolver.c -lm
./test_bc > tmp.out
if grep -q "PASS" tmp.out; then
echo "test_bc passed"
((PASS++))
else
echo "test_bc failed"
((FAIL++))
fi
rm -f test_bc tmp.out
}
# Test 3: Exact solution at a known point
test_exact() {
gcc -o test_exact test_exact.c PSolver.c -lm
./test_exact > tmp.out
result=$(cat tmp.out)
expected="0.707107" # sin(pi*0.5*0.5) ~ 0.7071
if [[ "$result" == "$expected" ]]; then
echo "test_exact passed"
((PASS++))
else
echo "test_exact failed: expected $expected, got $result"
((FAIL++))
fi
rm -f test_exact tmp.out
}
# Run tests
test_rms
test_bc
test_exact
# Report summary
echo ""
echo "Test Summary: $PASS passed, $FAIL failed"
if [[ $FAIL -eq 0 ]]; then
exit 0
else
exit 1
fi