I created an Ordered Test in Visual Studio 2008, which includes a subset of unit tests in the project.
How do I now run this Ordered Test (without running every other test).
I would like to quickly retrieve the median value from a boost multi_index container with an ordered_unique index, however the index iterators aren't random access (I don't understand why they can't be, though this is consistent with std::set...).
Is there a faster/neater way to do this other than incrementing an iterator container.size() / 2 times?
Hi all,
Boost serialization doc's assert that the way to serialize/deserialize items is using a binary/text archive with a stream on the underlying structure. This works fine if I wan't to use the serialized data as an std::string, but my intention is to convert it directly to a char* buffer. How can I achieve this without creating a temporary string?
hi.
I am trying to accomplish something like this:
thread t; // create/initialize thread
t.launch(); // launch thread.
t.wait(); // wait
t.launch(); // relaunch the same thread
How to go about implementing something like this using boost threads?
in essence, I need persistent relaunch-able thread.
Thanks
hello.
Is it possible to have scoped macros using custom defined macros through boost wave?
I know it should a possible with C++0x however I am working with regular C++.
If it is possible, can you provide link or reference how to accomplish this?
Thanks
Is there any good framework for comparing whole objects?
now i do
assertEquals("[email protected]", obj.email);
assertEquals("5", obj.shop);
if bad email is returned i never get to know if it had the right shop, i would like to get a list of incorrect fields.
template <typename T>
struct Foo
{
void operator()(T& t) { t(); }
};
Is there any standart or boost functor with the similar implementation?
I need it to iterate over container of functors:
std::for_each(beginIter, endIter, Foo<Bar>());
Or maybe there are other way to do it?
I am working in C++ with some legacy C code.
I have a data structure that (during initialisation), makes a copy of the structure pointed to a ptr passed to its initialisation pointer.
Here is a simplification of what I am trying to do - hopefully, no important detail has been lost in the "simplification":
/* C code */
typedef struct MyData
{
double * elems;
unsigned int len;
};
int NEW_mydata(MyData* data, unsigned int len)
{
// no error checking
data->elems = (double *)calloc(len, sizeof(double));
return 0;
}
typedef struct Foo
{
MyData data data_;
};
void InitFoo(Foo * foo, const MyData * the_data)
{
//alloc mem etc ... then assign the STRUCTURE
foo.data_ = *thedata ;
}
C++ code
-------------
typedef boost::shared_ptr<MyData> MyDataPtr;
typedef std::map<std::string, MyDataPtr> Datamap;
class FooWrapper
{
public:
FooWrapper(const std::string& key) {
MyDataPtr mdp = dmap[key];
InitFoo(&m_foo, const_cast<MyData*>((*mdp.get())));
}
~FooWrapper();
double get_element(unsigned int index ) const {
return m_foo.elems[index];
}
private:
// non copyable, non-assignable
FooWrapper(const FooWrapper&);
FooWrapper& operator= (const FooWrapper&);
Foo m_foo;
};
int main(int argc, char *argv[])
{
MyData data1, data2;
Datamap dmap;
NEW_mydata(&data1, 10);
data1->elems[0] = static_cast<double>(22/7);
NEW_mydata(&data2, 42);
data2->elems[0] = static_cast<double>(13/21);
boost::shared_ptr d1(&data1), d2(&data2);
dmap["data1"] = d1;
dmap["data2"] = d2;
FooWrapper fw("data1");
//expect 22/7, get something else (random number?)
double ret fw.get_element(0);
}
Essentially, what I want to know is this:
Is there any reason why the data retrieved from the map is different from the one stored in the map?
hi.
I was reading the boost endpoint documentation and saw
size() and resize() member funcs.
the documentation says: Gets the underlying size of the endpoint in the native type.
what does this size represent and where can it be used/resized ?
thanks.
Hi,
I have a graph with custom properties to the vertices and edges. I now want to create a copy of this graph, but I don't want the vertices to be as complex as in the original. By this I mean that it would suffice that the vertices have the same indices (vertex_index_t) as they do in the original graph.
Instead of doing the copying by hand I wanted to use the copy-functionality of boost::adjacency_list (s. http://www.boost.org/doc/libs/1_37_0/libs/graph/doc/adjacency_list.html):
template <class EdgeIterator>
adjacency_list(EdgeIterator first, EdgeIterator last,
vertices_size_type n,
edges_size_type m = 0,
const GraphProperty& p = GraphProperty())
The description there says:
The EdgeIterator must be a model of
InputIterator. The value type of the
EdgeIterator must be a std::pair,
where the type in the pair is an
integer type. The integers will
correspond to vertices, and they must
all fall in the range of [0, n).
Unfortunately I have to admit that I don't quite get it how to define an EdgeIterator that is a model of InputIterator.
Here's what I've succeded so far:
template< class EdgeIterator, class Edge >
class MyEdgeIterator// : public input_iterator< std::pair<int, int> >
{
public:
MyEdgeIterator() {};
MyEdgeIterator(EdgeIterator& rhs) : actual_edge_it_(rhs) {};
MyEdgeIterator(const MyEdgeIterator& to_copy) {};
bool operator==(const MyEdgeIterator& to_compare)
{
return actual_edge_it_ == to_compare.actual_edge_it_;
}
bool operator!=(const MyEdgeIterator& to_compare)
{
return !(*this == to_compare);
}
Edge operator*() const
{
return *actual_edge_it_;
}
const MyEdgeIterator* operator->() const;
MyEdgeIterator& operator ++()
{
++actual_edge_it_;
return *this;
}
MyEdgeIterator operator ++(int)
{
MyEdgeIterator<EdgeIterator, Edge> tmp = *this;
++*this;
return tmp;
}
private:
EdgeIterator& actual_edge_it_;
}
However, this doesn't work as it is supposed to and I ran out of clues.
So, how do I define the appropriate InputIterator?
I'm currently using the Visual Studio Installer (Setup Project) in Visual Studio 2010 as the installer for MyProgram. It has some quirky bugs and is not very customizable so I would like to switch to another installer product. Here are my requirements:
Must be free (and licensed for commercial use)
Must install the Windows Installer 3.1 and .NET Framework 4.0 if the client doesn't have them
The installer will download them if they are not available
The code for detecting the .NET Framework and downloading it must be written by Microsoft (I do not want to have to update hard-coded URLs and registry keys in the future). I know that the Windows SDK includes a setup bootstrap that does this (C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper)
In the future, when .NET Framework 5 is released and MyProgram uses it, no installer code will need to be changed, the updated installer product should see that MyProgram now uses the .NET Framework version 5 and will install that
Here are my current choices:
Visual Studio Installer:
Automatically detects/downloads/installs Windows Installer and .NET Framework using a bootstrapper Setup.exe (Good!)
Limited/buggy functionality (Uninstall shortcuts in the Start Menu cause empty folders to be left behind during uninstall, asking the user if they want a desktop shortcut requires a lot of work, etc.)
NSIS:
Doesn't natively support the .NET Framework so adding it as a prerequisite requires excessive coding, hardcoded URLS, etc.
Inno Setup:
Doesn't natively support the .NET Framework so adding it as a prerequisite requires excessive coding, hardcoded URLs, etc.
WiX:
Steep learning curve... not sure if I want to spend weeks learning it only to find out that it has the same uninstall problem as the Visual Studio Installer (because they both use MSI files)
InstallShield LE 2010:
Downloading it requires me to setup a fake email account to register just to download it. Then once it is installed it has to contact the company's servers and transmit some private information to them before I'm even allowed to try the free version. This is the most insidious form of DRM that there is and I will not accept it.
hi there
working on an iphone app and separate framework.
the separate framework is for an API that i'm building for use in multiple future apps.
this api now needs to reference resources (images). what i would like to do is keep the resources WITH the API framework as local set of resources.
i followed the instructions from http://www.clintharris.net/2009/iphone-app-shared-libraries/ to setup my app's project to use the headers from the separate API framework.
what i can't seem to figure out is how to automatically load the framework's resources into the app's xcode environment so they can be linked in at app compile time.
sure, i can drag the resources across from the framework into the main app's set of resources. but that seems kinda ugly and another step that possibly can be automated (??) anyone know of a better way? it would be great if any changes from the framework would be automatically available in the main app (due to the project 'link-age').
thanks for any help/tips/suggestions...
Last week (March 2010) I presented on Entity Framework 4 and the Windows Azure Platform at www.devweek.com. As usual, it was a great conference and I caught up with lots of old friends and made some new ones along the way. Entity Framework 4 Entity Framework 4 In Microsoft Visual Studio 2010 View more presentations from Eric Nelson. Windows Azure and SQL Azure Building An Application For Windows Azure And Sql Azure View more presentations from Eric Nelson. Entity Framework 4 Related Links Poll on Entity Framework 4 – one year on 101 EF4 Resources Recent resources on Entity Framework 4 Installing all the bits to demo Entity Framework 4 on the Visual Studio 2010 Release Candidate Azure Related Links UK Azure Online Community – join today. UK Windows Azure Site Start working with Windows Azure TCO and ROI calculator for Windows Azure
Starting new project using EJB 3 / JPA, mainly stateless session beans and batch jobs. I've used JUnit in the past on standard Java webapps and it seemed to work pretty well. In EJB2 unit testing was a pain and required a running container such as JBoss to make the calls into. Now that we're going to be working in EJB3 / JPA I'd like to know what companies are using to write and run these tests. Are Junit and JMock still considered relevant or are there other newer frameworks that have come around that we should investigate?
I've followed the Unit Testing Applications guide from the iPhone Development documentation. I followed all the steps and it worked with the TestCase from the documentation. But as soon as I changed the TestCase to test real Code from my project I ended up with linker errors. All classes that are used in the TestCase are reported as missing.
I've already searched the internet and found that the Bundle Loader property must be set to "$(BUILT_PRODUCTS_DIR)/MyApplication.app/Contents/MacOS/MyApplication". But this also fails because the file could not be found.
Any ideas what I have to do to tell the linker where to search for the missing files?
I have an odd situation. I have a suite of unit tests that pass on my dev machine. They pass on the build machine if run from visual studio. But 5 of them reliably fail during the automated build. There is nothing noteworthy about the ones that fail that I can see (and I've stared at them a long time). Anyone seen anything like this? Is there a way to see the test output in the Team Build log? All I get is Passed or Failed messages, but not the Assert message.
Thanks!
Hi everybody,
I'm going to write my own DAL in C#. I decided to use 'Unit of Work' pattern (next mentioned as uow) with request as a scope and Identity map stored in HttpContext.Items.
I have right now question about implementing of CRUD methods. How/where are they implemented? Are they implemented in every single business class (as in active records pattern) or are implemented somehow in uow class (if so, how)?
I also suppose that I need to use as the scope not just the request, but also the db connection. But how? Should I open the connection a the start of the request and close it on uow disposing?
Every advice is strongly appreciated, especially Your "real world" experiences.
Thank you all :)
I've got a pile of C code that I'd like to unittest using Python's unittest library (in Windows), but I'm trying to work out the best way of interfacing the C code so that Python can execute it (and get the results back). Does anybody have any experience in the easiest way to do it?
Some ideas include:
Wrapping the code as a Python C extension using the Python API
Wrap the C code using SWIG
Add a DLL wrapper to the C code and load it into Python using ctypes
Add a small XML-RPC server to the c-code and call it using xmlrpclib (yes, I know this seems a bit far-out!)
Is there a canonical way of doing this? I'm going to be doing this quite a lot, with different C modules, so I'd like to find a way which is least effort.
I program mostly in scala and java, using scalatest in scala and junit for unit testing. I would like to apply the very same tests to several implementations of the same interface/trait. The idea is to verify that the interface contract is enforced and to check Liskov substitution principle.
For instance, when testing implementations of lists, tests could include:
An instance should be empty, if and only if and only if it has zero size.
After calling clear, the size sould be zero.
Adding an element in the middle of a list, will increment by one the index of rhs elements.
etc.
What are the best practices ?
I've been off in Java land for about a month or so and now, upon returning to XCode I feel lost. I've upgraded 1st to 3.1.2 then recently to 3.2 and also got a new Mac with Snow Leopard so I'm not exactly sure when the problem surfaced. I just know that I used to get little red bubbles in my unittest next to the failing asserts and that no longer seems to happen. Is there a way to restore this? I've been trying to use Apple's own SenTesting framework instead of GoogleTools for mac like I used to. Should I revert to Google Tools? Does anyone have an answer?
Does anyone know of any guides or any sort of documentation on how to set up the new Flex Builder 4 beta? I've been pulling my hair all day long, none of my tests are executed and I can't for the life of me understand what's wrong. There are no errors at all. It's as if the metadata tags are not recognized, is there some special compiler argument to recognize them? I seem to remember that this is not necessary as long as the swc files that are included were compiled with said arguments.
I'm using Beta 1 of Flex Unit 4 which can be found here:
http://opensource.adobe.com/wiki/display/flexunit/FlexUnit+4+feature+overview
I'm actually using the very same code that is included with that package to run the tests, but no tests are executed. Neither mine nor the ones included in the FU4 package. The lack of documentation certainly doesn't help much...
Our toolkit has over 15000 JUnit tests, and many tests are known to fail if some other test fails. For example, if the method X.foo() uses functionality from Y.foo() and YTest.testFoo() fails, then XTest.testFoo() will fail too. Obviously, XTest.testFoo() can also fail because of problems specific to X.foo().
While this is fine and I still want both tests run, it would be nice if one could annotate a test dependency with XTest.testFoo() pointing to YTest.testFoo(). This way, one could immediately see what functionality used by X.foo() is also failing, and what not.
Is there such annotation available in JUnit or elsewhere? Something like:
public YTests {
@Test
@DependsOn(method=org.example.tests.YTest#testFoo)
public void testFoo() {
// Assert.something();
}
}
I'm adding unit-tests to an older PHP codebase at work. I will be testing and then rewriting a lot of HTML generation code and currently I'm just testing if the generated strings are identical to the expected string, like so: (using PHPUnit)
public function testConntype_select() {
$this->assertEquals(
'<select><option value="blabla">Some text</option></select>',
conntype_select(1); // A value from the test dataset.
);
}
This way has the downside that attribute ordering, whitespace and a lot of other irrelevant details are tested as well. I'm wondering if there are any better ways to do this. For example if there are any good and easy ways to compare the generated DOM trees. I found very similar questions for ruby, but couldn't find anything for PHP.