Skip to content

Commit

Permalink
Make these checks a little more lenient
Browse files Browse the repository at this point in the history
The exact strings of these exceptions change across versions and the
tests aren't for the exact string, just that something along those lines
gets thrown.
  • Loading branch information
jasonroelofs committed Dec 31, 2023
1 parent dbce443 commit 574cea8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
12 changes: 6 additions & 6 deletions test/test_Attribute.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <assert.h>
#include <assert.h>

#include "unittest.hpp"
#include "embed_ruby.hpp"
Expand Down Expand Up @@ -60,17 +60,17 @@ TESTCASE(attributes)
ASSERT_EXCEPTION_CHECK(
Exception,
o.call("read_char=", "some text"),
ASSERT_EQUAL("undefined method `read_char=' for :DataStruct", ex.what())
ASSERT(std::string(ex.what()).find("undefined method `read_char='") == 0)
);

// Test writeonly attribute
result = o.call("write_int=", 5);
ASSERT_EQUAL(5, detail::From_Ruby<int>().convert(result.value()));
ASSERT_EQUAL(5, dataStruct->writeInt);
ASSERT_EXCEPTION_CHECK(
Exception,
o.call("write_int", 3),
ASSERT_EQUAL("undefined method `write_int' for :DataStruct", ex.what())
ASSERT(std::string(ex.what()).find("undefined method `write_int'") == 0)
);

// Test readwrite attribute
Expand Down Expand Up @@ -101,7 +101,7 @@ TESTCASE(static_attributes)
ASSERT_EXCEPTION_CHECK(
Exception,
c.call("static_string=", true),
ASSERT_EQUAL("undefined method `static_string=' for DataStruct:Class", ex.what())
ASSERT(std::string(ex.what()).find("undefined method `static_string='") == 0)
);
}

Expand All @@ -127,7 +127,7 @@ TESTCASE(not_defined)
{
Data_Type<DataStruct> c = define_class<DataStruct>("DataStruct");

#ifdef _MSC_VER
#ifdef _MSC_VER
const char* message = "Type is not defined with Rice: class `anonymous namespace'::SomeClass";
#else
const char* message = "Type is not defined with Rice: (anonymous namespace)::SomeClass";
Expand Down
3 changes: 1 addition & 2 deletions test/test_Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ TESTCASE(call_with_keywords)
{
Module kernel = Module("Kernel");


Hash keywords;
keywords[":exception"] = false;
Object result = kernel.call("Integer", "charlie", keywords);
Expand Down Expand Up @@ -240,4 +239,4 @@ TESTCASE(test_mark)
Object o(INT2NUM(42));
rb_gc_start();
ASSERT_EQUAL(42, detail::From_Ruby<int>().convert(o.value()));
}
}
4 changes: 2 additions & 2 deletions test/test_To_From_Ruby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ TESTCASE(unsigned_long_long_from_ruby)
ASSERT_EXCEPTION_CHECK(
Exception,
detail::From_Ruby<unsigned long long>().convert(rb_str_new2("bad value")),
ASSERT_EQUAL("no implicit conversion from string", ex.what())
ASSERT(std::string(ex.what()).find("no implicit conversion") == 0)
);
}

Expand Down Expand Up @@ -396,4 +396,4 @@ TESTCASE(char_star_from_ruby)
detail::From_Ruby<const char*>().convert(rb_float_new(11.11)),
ASSERT_EQUAL("wrong argument type Float (expected String)", ex.what())
);
}
}

0 comments on commit 574cea8

Please sign in to comment.