-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_module.py
More file actions
60 lines (52 loc) · 1.61 KB
/
test_module.py
File metadata and controls
60 lines (52 loc) · 1.61 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
"""
Test script for the FluidX3D Python module
"""
import sys
import io
import fluidx3d
# Fix console encoding for Windows
if sys.platform == 'win32':
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
print("=" * 60)
print("FluidX3D Python Module Test")
print("=" * 60)
print(f"Version: {fluidx3d.__version__}")
print(f"Author: {fluidx3d.__author__}")
print()
# Test 1: No arguments (should fail)
print("Test 1: Validating with no arguments...")
try:
fluidx3d.validate_args([])
print(" ❌ UNEXPECTED: Should have raised an exception!")
except RuntimeError as e:
print(f" ✅ SUCCESS: Caught expected error: {e}")
print()
# Test 2: Valid arguments
print("Test 2: Validating with valid arguments (--D3Q27)...")
try:
result = fluidx3d.validate_args(['--D3Q27'])
print(f" ✅ SUCCESS: {result}")
except RuntimeError as e:
print(f" ❌ UNEXPECTED: {e}")
print()
# Test 3: Multiple velocity sets (should fail)
print("Test 3: Validating with multiple velocity sets...")
try:
fluidx3d.validate_args(['--D3Q27', '--D3Q19'])
print(" ❌ UNEXPECTED: Should have raised an exception!")
except RuntimeError as e:
print(f" ✅ SUCCESS: Caught expected error: {e}")
print()
# Test 4: Using the class interface
print("Test 4: Using ArgumentValidator class...")
validator = fluidx3d.ArgumentValidator()
print(f" Version from validator: {validator.get_version()}")
try:
validator.validate_args(['--D3Q19'])
print(" ✅ SUCCESS: Arguments validated!")
except RuntimeError as e:
print(f" ❌ UNEXPECTED: {e}")
print()
print("=" * 60)
print("All tests completed!")
print("=" * 60)