assertion

How to compare two objects for equality in Scala?

▼魔方 西西 提交于 2019-12-07 21:03:17
问题 I have a very basic equality check between two objects but it fails. package foo import org.junit.Assert._ object Sandbox extends App{ class A val a = new A val b = new A assertEquals(a, b) } My use-case is more complex but I wanted to get my basics right. I get an assertion error when I run the code: Caused by: java.lang.AssertionError: expected:<foo.Sandbox$A@3f86d38b> but was:<foo.Sandbox$A@206d63fd> at org.junit.Assert.fail(Assert.java:88) at org.junit.Assert.failNotEquals(Assert.java:743

Invalid < operator assertion in sort

会有一股神秘感。 提交于 2019-12-07 03:04:10
问题 I am trying to implement a simple comparator for sorting indices based on values in an array "_vec". I am getting an "invalid < operator" run-time error message. I fail to understand what is wrong with the following code: class Compare{ vector<int>& _vec; public: Compare(vector<int>& vec) : _vec(vec) {} bool operator()(size_t i, size_t j){ if(_vec[i] != _vec[j]) return _vec[i] < _vec[j]; else return (double)rand()/RAND_MAX < 0.5; } }; I am using the following function call: sort(inds.begin()

SAMLException: NameID element must be present as part of the Subject in the Response message, please enable it in the IDP configuration

你离开我真会死。 提交于 2019-12-06 05:23:31
问题 Iam using spring-saml implementation. In the class WebSSOProfileConsumerImpl, I could find the following lines of code which checks for nameId in the assertion of the SAML response . NameID nameID; if (subject.getEncryptedID() != null) { Assert.notNull(context.getLocalDecrypter(), "Can't decrypt NameID, no decrypter is set in the context"); nameID = (NameID) context.getLocalDecrypter().decrypt(subject.getEncryptedID()); } else { nameID = subject.getNameID(); } Based on the code, its clear

Change OpenCV image format to matlab format, debug assertion __acrt_first_block == header

孤街醉人 提交于 2019-12-05 18:09:07
I am trying to convert an OpenCV Image (of type cv::Mat) into matlab-style format as this is what the rest of the program quires. I am using the following code to do that: inline double* ConvertCVImageToMATLABImage(Mat &CvImage) { std::vector<cv::Mat> ColorChannels; // B, G, R channels cv::split(CvImage, ColorChannels); // remember to tranpose first because MATLAB is col-major!!! cv::transpose(ColorChannels[0], ColorChannels[0]); cv::transpose(ColorChannels[1], ColorChannels[1]); cv::transpose(ColorChannels[2], ColorChannels[2]); double *MatlabImage = new double[CvImage.rows*CvImage.cols * 3];

unittest for none type in python?

六月ゝ 毕业季﹏ 提交于 2019-12-05 13:22:09
问题 I was just wondering how I would go about testing for a function that does not return anything. for example, say I have this function: def is_in(char): my_list = [] my_list.append(char) and then if I were to test it: class TestIsIn(unittest.TestCase): def test_one(self): ''' Test if one character was added to the list''' self.assertEqual(self.is_in('a'), and this is where I am lost) I don't know what to assert the function is equal to, since there is no return value that I could compare it to

How to write custom PHPUnit assertion that behaves like built-in assertion?

為{幸葍}努か 提交于 2019-12-04 22:29:38
问题 How can I write a custom assertion, like assertFoo($expected, $actual) , that behaves like the built-in assertions with respect to the error "stack trace"? I currently have the following method defined (within a class that extends PHPUnit_Framework_TestCase ): public static function assertFoo($expected, $actual) { self::assertEquals($expected, $actual); } If I call this from a test and the test fails, I get two items in the call stack: 1) PreferencesTest::testSignupTeacher Failed asserting

org.hibernate.AssertionFailure: Unable to perform un-delete for instance

倖福魔咒の 提交于 2019-12-04 12:42:41
I am getting this hibernate assertion error, when i try to make a read after some delete operations. I couldn't find anything regarding this ' Unable to perform un-delete' error, except the soure code , so i think that, maybe i am doing something so obviously wrong... The stack trace is below, AssertionFailure:43 - - HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: Unable to perform un-delete for instance X org.hibernate.AssertionFailure: Unable to perform un-delete for instance

SAMLException: NameID element must be present as part of the Subject in the Response message, please enable it in the IDP configuration

人盡茶涼 提交于 2019-12-04 10:28:14
Iam using spring-saml implementation. In the class WebSSOProfileConsumerImpl, I could find the following lines of code which checks for nameId in the assertion of the SAML response . NameID nameID; if (subject.getEncryptedID() != null) { Assert.notNull(context.getLocalDecrypter(), "Can't decrypt NameID, no decrypter is set in the context"); nameID = (NameID) context.getLocalDecrypter().decrypt(subject.getEncryptedID()); } else { nameID = subject.getNameID(); } Based on the code, its clear that the nameId should be part of the subject. But most of the IDP's including the one that I am using

How to assert that two list contains elements with the same public properties in NUnit?

独自空忆成欢 提交于 2019-12-04 09:02:41
问题 I want to assert that the elements of two list contains values that I expected, something like: var foundCollection = fooManager.LoadFoo(); var expectedCollection = new List<Foo>() { new Foo() { Bar = "a", Bar2 = "b" }, new Foo() { Bar = "c", Bar2 = "d" } }; //assert: I use AreEquivalent since the order does not matter CollectionAssert.AreEquivalent(expectedCollection, foundCollection); However the above code will not work (I guess because .Equals() does not return true for different objects

Using assertion in the Linux kernel

◇◆丶佛笑我妖孽 提交于 2019-12-04 08:51:43
问题 I have a question about assert() in Linux: can I use it in the kernel? If no, what techniques do you usually use if, for example I don't want to enter NULL pointer? 回答1: The corresponding kernel macros are BUG_ON and WARN_ON . The former is for when you want to make the kernel panic and bring the system down (i.e., unrecoverable error). The latter is for when you want to log something to the kernel log (viewable via dmesg ). As @Michael says, in the kernel, you need to validate anything that