We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3719905 commit 1761a6eCopy full SHA for 1761a6e
test/sparse/sparse.jl
@@ -1135,14 +1135,19 @@ end
1135
A = sparse(["a", "b"])
1136
@test_throws MethodError findmin(A, 1)
1137
1138
-# Support the case, when user defined `zero` and `isless` for non-numerical type
1139
-#
1140
-Base.zero(::Type{T}) where T<:AbstractString = ""
1141
-for (tup, rval, rind) in [((1,), ["a"], [1])]
+# Support the case when user defined `zero` and `isless` for non-numerical type
+struct CustomType
+ x::String
+end
1142
+Base.zero(::Type{CustomType}) = CustomType("")
1143
+Base.isless(x::CustomType, y::CustomType) = isless(x.x, y.x)
1144
+A = sparse([CustomType("a"), CustomType("b")])
1145
+
1146
+for (tup, rval, rind) in [((1,), [CustomType("a")], [1])]
1147
@test isequal(findmin(A, tup), (rval, rind))
1148
end
1149
-for (tup, rval, rind) in [((1,), ["b"], [2])]
1150
+for (tup, rval, rind) in [((1,), [CustomType("b")], [2])]
1151
@test isequal(findmax(A, tup), (rval, rind))
1152
1153
0 commit comments