assertion

countNonZero function gives an assertion error in openCV

十年热恋 提交于 2019-11-29 04:32:25
I tried to get horizontal projection using countNonZero() function as below. Mat src = imread(INPUT_FILE, CV_LOAD_IMAGE_COLOR); Mat binaryImage = src.clone(); cvtColor(src, src, CV_BGR2GRAY); Mat horizontal = Mat::zeros(1,binaryImage.cols, CV_8UC1); for (int i = 0; i<binaryImage.cols; i++) { Mat roi = binaryImage(Rect(0, 0, 1, binaryImage.rows)); horizontal.at<int>(0,i) = countNonZero(roi); cout << "Col no:" << i << " >>" << horizontal.at<int>(0, i); } But an error is occured in the line of calling countonZero() function. Error is as follows. OpenCV Error: Assertion failed (src.channels() == 1

negative lookahead assertion not working in python

本小妞迷上赌 提交于 2019-11-29 02:20:39
Task: - given: a list of images filenames - todo: create a new list with filenames not containing the word "thumb" - i.e. only target the non-thumbnail images (with PIL - Python Imaging Library). I've tried r".*(?!thumb).*" but it failed. I've found the solution (here on stackoverflow) to prepend a ^ to the regex and to put the .* into the negative lookahead: r"^(?!.*thumb).*" and this now works. The thing is, I would like to understand why my first solution did not work but I don't. Since regexes are complicated enough, I would really like to understand them. What I do understand is that the

Assert that a WebElement is not present using Selenium WebDriver with java

北城余情 提交于 2019-11-29 00:56:32
In tests that I write, if I want to assert a WebElement is present on the page, I can do a simple: driver.findElement(By.linkText("Test Search")); This will pass if it exists and it will bomb out if it does not exist. But now I want to assert that a link does not exist. I am unclear how to do this since the code above does not return a boolean. EDIT This is how I came up with my own fix, I'm wondering if there's a better way out there still. public static void assertLinkNotPresent (WebDriver driver, String text) throws Exception { List<WebElement> bob = driver.findElements(By.linkText(text));

Best way to check that element is not present using Selenium WebDriver with java

青春壹個敷衍的年華 提交于 2019-11-28 21:15:11
问题 Im trying the code below but it seems it does not work... Can someone show me the best way to do this? public void verifyThatCommentDeleted(final String text) throws Exception { new WebDriverWait(driver, 5).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver input) { try { input.findElement(By.xpath(String.format( Locators.CHECK_TEXT_IN_FIRST_STATUS_BOX, text))); return false; } catch (NoSuchElementException e) { return true; } } }); } 回答1: i usually couple of

Java assertions underused

喜你入骨 提交于 2019-11-28 17:22:11
I'm wondering why the assert keyword is so underused in Java? I've almost never seen them used, but I think they're a great idea. I certainly much prefer the brevity of: assert param != null : "Param cannot be null"; to the verbosity of: if (param == null) { throw new IllegalArgumentException("Param cannot be null"); } My suspicion is that they're underused because They arrived relatively late (Java 1.4), by which time many people had already established their Java programming style/habit They are turned off at runtime by default Ken Gentle assertions are, in theory, for testing invariants ,

How do I assert my exception message with JUnit Test annotation?

主宰稳场 提交于 2019-11-28 14:59:06
I have written a few JUnit tests with @Test annotation. If my test method throws a checked exception and if I want to assert the message along with the exception, is there a way to do so with JUnit @Test annotation? AFAIK, JUnit 4.7 doesn't provide this feature but does any future versions provide it? I know in .NET you can assert the message and the exception class. Looking for similar feature in the Java world. This is what I want: @Test (expected = RuntimeException.class, message = "Employee ID is null") public void shouldThrowRuntimeExceptionWhenEmployeeIDisNull() {} Jesse Merriman You

C++ assertion error while deleting object

不想你离开。 提交于 2019-11-28 13:21:29
问题 I have strange assertion error and I can not find what is wrong with this code. Assertion expression is _BLOCK_TYPE_IS_VALID(pHead->nBlockUse). I simplified code a bit for better readability. class Creator { public: virtual ~Creator() { for (MyObject* item : _list) { delete item; <-- assertion error here item = 0; } _list.clear(); } template <class T> T& create() { T * item = new T(); _list.push_back(item); return *item; } private: std::list<MyObject*> _list; }; class A : public MyObject,

golang type assertion using reflect.Typeof()

女生的网名这么多〃 提交于 2019-11-28 09:58:17
I've tried to identify a struct with string value(name). reflect.TypeOf returns Type . But type assertion needs a type . How can I casting Type to type ? Or any suggestion to handle it? http://play.golang.org/p/3PJG3YxIyf package main import ( "fmt" "reflect" ) type Article struct { Id int64 `json:"id"` Title string `json:"title",sql:"size:255"` Content string `json:"content"` } func IdentifyItemType(name string) interface{} { var item interface{} switch name { default: item = Article{} } return item } func main() { i := IdentifyItemType("name") item := i.(Article) fmt.Printf("Hello, item : %v

Debug Assertion Failed: _CrtIsValidHeapPointer(pUserData)

怎甘沉沦 提交于 2019-11-28 08:00:21
问题 Sometimes I get this "Debug Assertion Failed" error running my Qt project in debug mode (image). I don't know where I wrong because the compiler says nothing and I don't know what to do to find my error. I program under Windows Vista, using Qt Creator 2.4.1, Qt 4.8.1. My program has to read some informations from a laser device and save them into a file with a code similar to this: void runFunction() { configure_Scanning(...); while(...) { // do something scanFunction(); // do something } }

getPageSource() in Selenium WebDriver(a.k.a Selenium2) using Java

坚强是说给别人听的谎言 提交于 2019-11-28 03:29:56
问题 How can I view the source of a page between the "title" and "meta" tags using Selenium WebDriver with Java? 回答1: You can try driver.getPageSource() after you have loaded the page. link to java doc 回答2: You can compare the Title of a page as below code: String actualTitle = driver.getTitle(); String expectedTitle = "My Title"; assertEquals(actualTitle, expectedTitle); If you want to get page source you can get by using the following java code: String pageSource = driver.getPageSource(); If you