Skip to content

Commit f66c5f4

Browse files
authored
Merge pull request #44 from Sov-trotter/tests_improv
Improve tests and minor fixes
2 parents b299022 + af1d4fd commit f66c5f4

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

src/offsetintegers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
OffsetInteger type mainly for indexing.
66
* `O` - The offset relative to Julia arrays. This helps reduce copying when
7-
communicating with 0-indexed systems such ad OpenGL.
7+
communicating with 0-indexed systems such as OpenGL.
88
"""
99
struct OffsetInteger{O, T <: Integer} <: Integer
1010
i::T

test/geometrytypes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ end
295295
rect2 = Rect(0.0, 0.0, 2.0, 1.0)
296296
@test !overlaps(rect1, rect2)
297297
rect1 = Rect(1.0, 1.0, 2.0, 2.0)
298-
rect2 = Rect(1.0, 1.0, 2.0, 2.0)
299-
@test !overlaps(rect1, rect2)
298+
rect2 = Rect(1.5, 1.5, 2.0, 2.0)
299+
@test overlaps(rect1, rect2)
300300

301301

302302
rect1 = Rect(1.0, 1.0, 2.0, 2.0)

test/runtests.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ using LinearAlgebra
7575
filtered = filter(i -> i.value < 0.7, x)
7676
@test length(filtered) == 7
7777
end
78+
@test GeometryBasics.getcolumn(plain, :name) == pnames
79+
@test GeometryBasics.MetaType(Polygon) == PolygonMeta{Polygon,T,Typ,Names,Types} where Types where Names where Typ<:GeometryBasics.AbstractPolygon{Polygon,T} where T
80+
@test_throws ErrorException GeometryBasics.meta(plain)
81+
@test GeometryBasics.MetaFree(PolygonMeta) == Polygon
82+
7883
end
7984

8085
@testset "point with metadata" begin
@@ -360,7 +365,10 @@ end
360365

361366
@test hasproperty(m, :xx)
362367
@test hasproperty(m, :color)
368+
@test_throws ErrorException GeometryBasics.MetaType(Simplex)
369+
@test_throws ErrorException GeometryBasics.MetaFree(Simplex)
363370

371+
364372
@test m.xx === xx
365373
@test m.color === color
366374

@@ -421,5 +429,35 @@ end
421429
@test found && point Point(0.0, 4.0)
422430
@test intersects(a, f) === (false, Point(0.0, 0.0))
423431
end
432+
@testset "Offsetintegers" begin
433+
x = 1
434+
@test GeometryBasics.raw(x) isa Int64
435+
@test GeometryBasics.value(x) == x
436+
437+
x = ZeroIndex(1)
438+
@test eltype(x) == Int64
439+
440+
x = OffsetInteger{0}(1)
441+
@test typeof(x) == OffsetInteger{0,Int64}
442+
443+
x1 = OffsetInteger{0}(2)
444+
@test GeometryBasics.pure_max(x, x1) == x1
445+
@test promote_rule(typeof(x), typeof(x1)) == OffsetInteger{0,Int64}
446+
x2 = 1
447+
@test promote_rule(typeof(x2), typeof(x1)) == Int64
448+
@test Base.to_index(x1) == 2
449+
@test -(x1) == OffsetInteger{0,Int64}(-2)
450+
@test abs(x1) == OffsetInteger{0,Int64}(2)
451+
@test +(x, x1) == OffsetInteger{0,Int64}(3)
452+
@test *(x, x1) == OffsetInteger{0,Int64}(2)
453+
@test -(x, x1) == OffsetInteger{0,Int64}(-1)
454+
#test for /
455+
@test div(x, x1) == OffsetInteger{0,Int64}(0)
456+
@test !==(x, x1)
457+
@test !>=(x, x1)
458+
@test <=(x, x1)
459+
@test !>(x, x1)
460+
@test <(x, x1)
461+
end
424462

425463
end # testset "GeometryBasics"

0 commit comments

Comments
 (0)