How to create regex pattern which is concatenate with variable, something like this:
var test ="52";
var re = new RegExp("/\b"+test+"\b/");
alert('51,52,53'.match(re));
Thanks
Hi,
I have a question relating to alignment in c/c++. In
http://stackoverflow.com/questions/364483/determining-the-alignment-of-c-c-structures-in-relation-to-its-members Michael Burr posted this Makro:
#define TYPE_ALIGNMENT( t ) offsetof( struct { char x; t test; }, test )
in the comments someone wrote this might fail with non POD typs. Can someone give me an code example where this fails?
I have read so many places is that if your code is not test-able that mean code is not well written. So that makes me start writing a code that is test-able and to start using some unit testing framework.
With this though I start looking for some example with piece of code that is not testable and gradually converted to a testable code. I find tons of examples on unit testing but if someone can provide an example like above it probably can jump start things for me.
TIA
I want to check if a page returns the status code 401. Is this possible?
Here is my try, but it only returns 0.
$.ajax({
url: "http://my-ip/test/test.php",
data: {},
complete: function(xhr, statusText){
alert(xhr.status);
}
});
Is there any way to change indentation style for automatically generated code in Eclipse?
I'd like to change from
class Test {
blah blah
}
to
class Test
{
blah blah
}
All tests should be run with jUnit3, if i run a non-configured Test, it tries to use the default-TestRunner (jUnit4).
So, i have to go into the run/debug configuration, change the TestRunner to "jUnit3" and run it again.
On EVERY Test. This just disturbs the workflow.
So, is there an option to REMOVE jUnit4 as possible TestRunner, or even better, change the Default TestRunner to jUnit3 ?
Thanks in Advance,
Where can I test HTML 5 functionality today - is there any test build of any rendering engines which would allow testing, or is it to early? I'm aware that much of the spec hasn't been finalised, but some has, and it would be good to try it out!
Hi,
I'm developing a operating system and I need a test program (function of any kind) to test certain internal features.
I cannot find any appropriate program to do this job. Probably one of you knows one.
The program should be open source, written in C with very little user library usage (only file IO, pthreads, stdio, stdlib preferred) and must have a binary size of at least 2MB.
Thanks for any suggestions.
I'm trying to bind a float to a postgresql double precision using psycopg2.
ele = 1.0/3.0
dic = {'name': 'test', 'ele': ele}
sql = '''insert into waypoints (name, elevation) values (%(name)s, %(ele)s)'''
cur = db.cursor()
cur.execute(sql, dic)
db.commit()
sql = """select elevation from waypoints where name = 'test'"""
cur.execute(sql_out)
ele_out = cur.fetchone()[0]
ele_out
0.33333333333300003
ele
0.33333333333333331
Obviously I don't need the precision, but I would like to be able to simply compare the values. I could use the struct module and save it as a string, but thought there should be a better way. Thanks
Hello,
I have an array in PHP which looks like that:
$test = array('3' => 5);
How could I replace the stringed array key 3?
I tried:
$test['3'] = "New value"
but it don't work, it look like that after that:
array('3' => 5, 3 => "New value")
I have an html document located on http://somedomain.com/somedir/example.html
The document contains of four links:
http://otherdomain.com/other.html
http://somedomain.com/other.html
/only.html
test.html
How I can get the full urls for the links in the current domain ?
I mean I should get:
http://somedomain.com/other.html
http://somedomain.com/only.html
http://somedomain.com/somedir/test.html
The first link should be ignored because it does'nt match my domain
If you put the aif code presented in onlisp in a package and try to use it in another you run in the problem that packagename:it is not external.
(in-package :packagename)
(defmacro aif (test-form then-form &optional else-form)
‘(let ((it ,test-form))
(if it ,then-form ,else-form)))
wanted call syntax
(in-package :otherpackage)
(aif (do-stuff)
(FORMAT t "~a~%" it)
(FORMAT t "just got nil~%"))
How can I fix this behavior in code, without making the variable it external in the package declaration and beeing able to access it just by it instead of packagename:it?
I have written a program in C# that sends text to COMx.
I wish to test it using HyperTerminal, meaning I want to read the text that I send with my program. When I set the WAIT FOR CALL in HyperTerminal, my program is refused access to the given port.
How can I test my program? Is it possible?
Hi all,
I would like to dynamically create a PHP object, and parameters would be optional.
For example, instead of doing this:
$test = new Obj($param);
I would like to do something like this (create new ob is fictional):
$test = create_new_obj('Obj', $param);
Is there such function in php? Something similar to call_user_func_array, but for object instead.
Suppose that I have created a method like this
private void Test<t>(t str)
{
}
Now from another method i call it
private void BtnClick()
{
string a = "";
test<Here I Want To assign The Type what ever the type of 'a' is>();
}
How can I do this ?
To get any code with SoftReference<T> to be fully tested, one must come up with some way to test the 'yup, it's been nulled' case. One might more or less mock this by using a 'for-test' code path to force the reference to be null, but that won't manage the queue exactly as the GC does. I wonder if anyone out can share experience in setting up a repeatable, controlled, environment, in which the GC is, in fact, provoked into collecting and nulling?
Hi Friends,
I would like to test iPhone applications to test on device. I am in confusion on the version of iPhone which suits best for iPhone application development.
Can anyOne of you suggest me, is 2G OR 3G better? Its Urgent..
Thank You.
Hi,
Is there a variable where we can find out the root directory of my Grails application?
I tried request.getSession().getServletContext().getRealPath("/")
But shows tmp/App-Test-0.1/ .
My app is located in tomcat "/home/srinath/work/projects/tomcat-6.0.18/webapps/App-Test-0.1"
could any one help me .
thanks in advance,
sri..
In the Javascript Shell, I click the browser.xul link and:
$.ajax({url:'http://www.test.com/', async: false}).responseText; works
(async default is true)
$.ajax({url:'http://www.test.com/'}).responseText; doesn't work
what are the ways to make it work?
This piece of code is very slow. Execution from the slime-repl on my netbook takes a couple minutes. Am I doing something wrong?
(def test-array (make-array Integer/TYPE 400 400 3))
(doseq [x (range 400), y (range 400), z (range 3)]
(aset test-array x y z 0))
I have several different test classes that require that certain objects are created before those tests can be run. Now I'm wondering if I should put the object initialization code into a separate helper class or superclass.
Doing so would surely reduce the amount of duplicate code in my test classes but it would also make them less readable.
Is there a guideline or pattern how to deal with common setUp-code for unit tests?
Really simple question, how do I combine echo and cat in the shell, I'm trying to write the contents of a file into another file with a prepended string?
If /tmp/file looks like this:
this is a test
I want to run this:
echo "PREPENDED STRING"
cat /tmp/file | sed 's/test/test2/g' > /tmp/result
so that /tmp/result looks like this:
PREPENDED STRINGthis is a test2
Thanks.
Is there is way to compress JavaScript code?
e.g.
function test(){
// some code here
}
after compression it should be
function test(){//some code here}
Also, I need vise versa at the time of editing the code.
I am currently trying to create a test suite for my javascript apps. My problem is that, it seems I cannot get access to init() from my utils object, as you can see below:
I have my app that follow a singleton pattern:
var appModal = function () {
var utils = Object.create(moduleUtils);
function init(caller, options ) {
}
}();
My test suite is in moduleUtils, this is a object literal converted to a prototype
moduleUtils.debug = {
addSlideTest : function(){
/* this function cannot fire init() from appModal */
}}
Hello,
I have a statement:
I have a string such as
content = "* test *"
I want to search and replace it with so when I am done the string contains this:
content = "(*) test (*)"
My code is:
content = Regex.Replace(content, "*", "(*)");
But this causes an error in C# because it thinks that the * is part of the Regular Expressions Syntax.
How can I modify this code so it changes all asterisks in my string to (*) instead without causing a runtime error?
Thanks.