|
290 | 290 | @test isfinite(res.equation_of_time) |
291 | 291 | end |
292 | 292 | end |
| 293 | + |
| 294 | +@testset "Base.show methods" begin |
| 295 | + @testset "Observer show" begin |
| 296 | + obs = Observer(45.0, 10.0, 100.0) |
| 297 | + str = sprint(show, obs) |
| 298 | + @test occursin("Observer", str) |
| 299 | + @test occursin("45.0", str) |
| 300 | + @test occursin("10.0", str) |
| 301 | + @test occursin("100.0", str) |
| 302 | + end |
| 303 | + |
| 304 | + @testset "SolPos show" begin |
| 305 | + pos = SolPos(180.0, 45.0, 45.0) |
| 306 | + str = sprint(show, pos) |
| 307 | + @test occursin("SolPos", str) |
| 308 | + @test occursin("180.0", str) |
| 309 | + @test occursin("45.0", str) |
| 310 | + end |
| 311 | + |
| 312 | + @testset "ApparentSolPos show" begin |
| 313 | + pos = ApparentSolPos(180.0, 45.0, 45.0, 46.0, 44.0) |
| 314 | + str = sprint(show, pos) |
| 315 | + @test occursin("ApparentSolPos", str) |
| 316 | + @test occursin("180.0", str) |
| 317 | + @test occursin("45.0", str) |
| 318 | + @test occursin("46.0", str) |
| 319 | + @test occursin("44.0", str) |
| 320 | + end |
| 321 | + |
| 322 | + @testset "SPASolPos show" begin |
| 323 | + pos = SPASolPos(180.0, 45.0, 45.0, 46.0, 44.0, 5.0) |
| 324 | + str = sprint(show, pos) |
| 325 | + @test occursin("SPASolPos", str) |
| 326 | + @test occursin("180.0", str) |
| 327 | + @test occursin("45.0", str) |
| 328 | + @test occursin("5.0", str) |
| 329 | + end |
| 330 | +end |
| 331 | + |
| 332 | +@testset "Union{DateTime,ZonedDateTime} vector handling" begin |
| 333 | + obs = Observer(45.0, 10.0, 100.0) |
| 334 | + dt1 = DateTime(2020, 6, 21, 12, 0, 0) |
| 335 | + dt2 = ZonedDateTime(2020, 6, 21, 13, 0, 0, tz"UTC") |
| 336 | + |
| 337 | + # mixed vector of DateTime and ZonedDateTime |
| 338 | + dts = Union{DateTime,ZonedDateTime}[dt1, dt2] |
| 339 | + positions = solar_position(obs, dts, PSA()) |
| 340 | + @test length(positions) == 2 |
| 341 | + @test positions isa StructVector |
| 342 | + |
| 343 | + # in-place version |
| 344 | + pos = StructVector{SolPos{Float64}}(undef, 2) |
| 345 | + solar_position!(pos, obs, dts, PSA()) |
| 346 | + @test length(pos) == 2 |
| 347 | + @test all(p -> p isa SolPos, pos) |
| 348 | +end |
| 349 | + |
| 350 | +@testset "Table interface with copy" begin |
| 351 | + # non-mutating solar_position function for tables |
| 352 | + obs = Observer(45.0, 10.0, 100.0) |
| 353 | + df = DataFrame( |
| 354 | + datetime = [DateTime(2020, 6, 21, 12, 0, 0), DateTime(2020, 6, 21, 13, 0, 0)], |
| 355 | + ) |
| 356 | + |
| 357 | + # returns copy |
| 358 | + df_result = solar_position(df, obs, PSA()) |
| 359 | + |
| 360 | + # should not be modified |
| 361 | + @test !hasproperty(df, :azimuth) |
| 362 | + @test hasproperty(df_result, :azimuth) |
| 363 | + @test hasproperty(df_result, :elevation) |
| 364 | + @test hasproperty(df_result, :zenith) |
| 365 | +end |
0 commit comments