diff --git a/Project.toml b/Project.toml index f1c993d..3150d03 100644 --- a/Project.toml +++ b/Project.toml @@ -8,3 +8,9 @@ ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" + +[extras] +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Test"] diff --git a/src/parser.jl b/src/parser.jl index 4d1703c..cbe8231 100644 --- a/src/parser.jl +++ b/src/parser.jl @@ -30,9 +30,11 @@ function parse_log(filepath::AbstractString; interactive=false)::Vector{CoordLog istracing = true coords_trace = Vector{Vector{Float64}}(undef, 0) # SVector ? log_date = try - s = match(r"\".+\"").match - parse(DateTime, s[2:end-1]) + s = match(r"\".+\"", l) + @debug s + parse(DateTime, s.match[2:end-1]) catch e + @debug l @error "Failed to parse date at line $(i), file $(filepath)" DateTime(0) end diff --git a/test/runtests.jl b/test/runtests.jl index e69de29..d0f805e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -0,0 +1,27 @@ +using CoordVisualize +using Dates +using Test + +@testset "CoordVisualize" begin + sample_log_1 = CoordVisualize.CoordLog[CoordVisualize.CoordLog{Float64}([-54.0 -10.000000953674 -35.000003814697; -54.0 -10.000000953674 -35.000003814697; -54.0 -10.000000953674 -36.013381958008; -54.0 -10.000000953674 -37.615753173828; -54.0 -10.000000953674 -39.261665344238; -54.0 -10.000000953674 -40.727695465088; -54.0 -10.000000953674 -42.168701171875; -54.0 -10.000000953674 -43.820377349854; -54.0 -11.018865585327 -47.018901824951; -54.0 -14.0 -51.176284790039; -54.663269042969 -14.0 -55.0; -58.297706604004 -14.0 -55.0; -63.16588973999 -16.0 -55.0; -66.000007629395 -16.0 -55.526763916016; -66.000007629395 -16.0 -59.460041046143; -66.000007629395 -16.0 -63.24658203125; -66.000007629395 -16.0 -67.261924743652; -66.000007629395 -16.0 -71.199310302734], Dates.DateTime("2023-10-22T10:02:04"), "")] + + sample_log_2 = CoordVisualize.CoordLog{Float64}([895.0 7.0 -978.0; 895.0 7.0 -978.0; 895.0 7.0 -977.38684082031; 895.0 7.0 -975.71923828125; 897.0 7.0 -974.39855957031; 898.80633544922 7.0 -973.0; 901.38275146484 7.0 -973.0; 904.18518066406 7.0 -973.0; 907.25793457031 7.0 -973.0; 911.19061279297 7.0 -973.0; 915.05682373047 7.0 -973.0; 919.1259765625 7.0 -973.0; 923.12609863281 7.0 -973.0; 926.94378662109 7.0 -973.0; 930.82952880859 7.0 -973.0; 934.84539794922 7.0 -973.0; 938.83020019531 7.0 -973.0; 944.04681396484 8.0 -973.0; 948.01483154297 8.0148372650146 -973.0; 951.48193359375 9.0000009536743 -973.0; 955.5927734375 10.000000953674 -973.0; 954.96008300781 10.000000953674 -973.0; 958.39764404297 11.000000953674 -973.0; 962.41009521484 12.000000953674 -973.0; 966.17108154297 12.000000953674 -973.0; 969.40936279297 12.000000953674 -973.0; 969.47576904297 13.0 -973.0; 973.32684326172 13.0 -973.0; 977.21990966797 13.0 -973.0; 981.09814453125 13.0 -973.0; 985.05871582031 13.0 -973.0; 989.03479003906 13.0 -973.0; 992.83026123047 13.0 -973.0; 996.90203857422 13.0 -973.0], DateTime("0000-01-01T00:00:00"), "") + + @testset "parse" begin + sample_result = CoordVisualize.parse_log("sample_log.txt"; interactive=false) + @debug sample_result + @testset "parse with datetime" begin + @debug sample_result[1] + @test length(sample_result) == 2 + @test sample_result[1].coords == sample_log_1[1].coords + @test sample_result[1].logdate == sample_log_1[1].logdate + @test sample_result[1].note == sample_log_1[1].note + end + + @testset "parse without datetime" begin + @test sample_result[2].coords == sample_log_2.coords + @test sample_result[2].logdate == sample_log_2.logdate + @test sample_result[2].note == sample_log_2.note + end + end +end diff --git a/test/sample_log.txt b/test/sample_log.txt new file mode 100644 index 0000000..81849f3 --- /dev/null +++ b/test/sample_log.txt @@ -0,0 +1,65 @@ +2023-10-16 21:50:10: WARNING[Main]: Couldn't find a locale directory! +2023-10-16 21:50:17: WARNING[Main]: Irrlicht: PNG warning: iCCP: known incorrect sRGB profile +2023-10-16 21:50:17: WARNING[Main]: Irrlicht: PNG warning: iCCP: known incorrect sRGB profile +2023-10-16 21:50:17: WARNING[Main]: Irrlicht: PNG warning: iCCP: known incorrect sRGB profile +[TRACECOORDS] loaded tracecoords mod +[TRACECOORDS] Logging starting... "2023-10-22T10:02:04" +[TRACECOORDS] Coordinate:(-54,-10.000000953674,-35.000003814697) +[TRACECOORDS] Coordinate:(-54,-10.000000953674,-35.000003814697) +[TRACECOORDS] Coordinate:(-54,-10.000000953674,-36.013381958008) +[TRACECOORDS] Coordinate:(-54,-10.000000953674,-37.615753173828) +[TRACECOORDS] Coordinate:(-54,-10.000000953674,-39.261665344238) +2023-10-16 21:50:34: WARNING[Main]: Irrlicht: Could not open file of texture: defense_paniki.png +[TRACECOORDS] Coordinate:(-54,-10.000000953674,-40.727695465088) +[TRACECOORDS] Coordinate:(-54,-10.000000953674,-42.168701171875) +[TRACECOORDS] Coordinate:(-54,-10.000000953674,-43.820377349854) +[TRACECOORDS] Coordinate:(-54,-11.018865585327,-47.018901824951) +some random stringfdsjak +[TRACECOORDS] Coordinate:(-54,-14,-51.176284790039) +[TRACECOORDS] Coordinate:(-54.663269042969,-14,-55) +[TRACECOORDS] Coordinate:(-58.297706604004,-14,-55) +[TRACECOORDS] Coordinate:(-63.16588973999,-16,-55) +[TRACECOORDS] Coordinate:(-66.000007629395,-16,-55.526763916016) +[TRACECOORDS] Coordinate:(-66.000007629395,-16,-59.460041046143) +[TRACECOORDS] Coordinate:(-66.000007629395,-16,-63.24658203125) +[TRACECOORDS] Coordinate:(-66.000007629395,-16,-67.261924743652) +[TRACECOORDS] Coordinate:(-66.000007629395,-16,-71.199310302734) +[TRACECOORDS] Logging stopping... "2023-10-22T18:28:01" +[TRACECOORDS] shutdown client +[TRACECOORDS] Logging starting... +[TRACECOORDS] Coordinate:(895,7,-978) +[TRACECOORDS] Coordinate:(895,7,-978) +[TRACECOORDS] Coordinate:(895,7,-977.38684082031) +[TRACECOORDS] Coordinate:(895,7,-975.71923828125) +[TRACECOORDS] Coordinate:(897,7,-974.39855957031) +[TRACECOORDS] Coordinate:(898.80633544922,7,-973) +[TRACECOORDS] Coordinate:(901.38275146484,7,-973) +[TRACECOORDS] Coordinate:(904.18518066406,7,-973) +[TRACECOORDS] Coordinate:(907.25793457031,7,-973) +[TRACECOORDS] Coordinate:(911.19061279297,7,-973) +[TRACECOORDS] Coordinate:(915.05682373047,7,-973) +[TRACECOORDS] Coordinate:(919.1259765625,7,-973) +[TRACECOORDS] Coordinate:(923.12609863281,7,-973) +[TRACECOORDS] Coordinate:(926.94378662109,7,-973) +[TRACECOORDS] Coordinate:(930.82952880859,7,-973) +[TRACECOORDS] Coordinate:(934.84539794922,7,-973) +[TRACECOORDS] Coordinate:(938.83020019531,7,-973) +[TRACECOORDS] Coordinate:(944.04681396484,8,-973) +[TRACECOORDS] Coordinate:(948.01483154297,8.0148372650146,-973) +[TRACECOORDS] Coordinate:(951.48193359375,9.0000009536743,-973) +[TRACECOORDS] Coordinate:(955.5927734375,10.000000953674,-973) +[TRACECOORDS] Coordinate:(954.96008300781,10.000000953674,-973) +[TRACECOORDS] Coordinate:(958.39764404297,11.000000953674,-973) +[TRACECOORDS] Coordinate:(962.41009521484,12.000000953674,-973) +[TRACECOORDS] Coordinate:(966.17108154297,12.000000953674,-973) +[TRACECOORDS] Coordinate:(969.40936279297,12.000000953674,-973) +[TRACECOORDS] Coordinate:(969.47576904297,13,-973) +[TRACECOORDS] Coordinate:(973.32684326172,13,-973) +[TRACECOORDS] Coordinate:(977.21990966797,13,-973) +[TRACECOORDS] Coordinate:(981.09814453125,13,-973) +[TRACECOORDS] Coordinate:(985.05871582031,13,-973) +[TRACECOORDS] Coordinate:(989.03479003906,13,-973) +[TRACECOORDS] Coordinate:(992.83026123047,13,-973) +[TRACECOORDS] Coordinate:(996.90203857422,13,-973) +[TRACECOORDS] Logging stopping... +[TRACECOORDS] shutdown client