1
- using Test
2
- using ReadDBC
1
+
2
+ using Test # Import the Test package to write test cases
3
+ using ReadDBC # Import your module to test its functions
3
4
using DataFrames
4
5
6
+ # Define paths for test input and expected output
7
+ input_file = " src/ABOAC1909.dbc"
8
+ output_file = " src/ABOAC1909.dbf"
5
9
6
- # Test the dbctodbf function
7
- @testset " ReadDBC Tests" begin
8
- # Set up file paths
9
- input_file = " src/ABOAC1909.dbc"
10
- output_file = " src/ABOAC1909.dbf"
11
- dbctodbf (input_file, output_file)
12
-
13
- # Check if the output file is created (basic test)
14
- @test isfile (output_file)
10
+ @testset " ReadDBC Module Tests" begin
15
11
16
- # Clean up (remove files)
17
- rm (output_file)
18
- end
12
+ # Test 1: Test dbctodbf function
13
+ @testset " Test dbctodbf" begin
14
+ @test isfile (input_file) # Check if the input file exists
15
+ result = dbctodbf (input_file, output_file) # Call the function
16
+ @test result == output_file # Ensure the output file path is returned
17
+ @test isfile (output_file) # Check if the output file was created
18
+ end
19
19
20
- # Test the readdbc function
21
- @testset " ReadDBC Tests" begin
22
- # Set up file paths
23
- input_file = " src/ABOAC1909.dbc"
24
- output_file = replace (input_file, " .dbc" => " .dbf" )
25
-
26
- # Call the readdbc function
27
- df = dbcTable (input_file)
28
-
29
- # Ensure the DataFrame is returned and is not empty (this depends on actual implementation)
30
- @test df != = nothing
31
- @test isa (df, DataFrame)
32
-
33
- # Add more tests as needed, for example, checking specific columns or data in the DataFrame
34
-
35
- # Clean up (remove files)
36
- rm (output_file)
37
- end
20
+ # Test 2: Test dbcTable function
21
+ @testset " Test dbcTable" begin
22
+ df = dbcTable (input_file) # Call the function to convert and read
23
+ @test df != = nothing # Ensure the DataFrame is not empty
24
+ @test isa (df, DataFrame) # Ensure the result is a DataFrame
25
+ @test nrow (df) > 0 # Ensure the DataFrame has rows
26
+ end
38
27
39
- println ( " All tests passed successfully. " )
28
+ end
0 commit comments