Search Results

Search found 22986 results on 920 pages for 'allocation unit size'.

Page 11/920 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Unit Testing Private Method in Resource Managing Class (C++)

    - by BillyONeal
    I previously asked this question under another name but deleted it because I didn't explain it very well. Let's say I have a class which manages a file. Let's say that this class treats the file as having a specific file format, and contains methods to perform operations on this file: class Foo { std::wstring fileName_; public: Foo(const std::wstring& fileName) : fileName_(fileName) { //Construct a Foo here. }; int getChecksum() { //Open the file and read some part of it //Long method to figure out what checksum it is. //Return the checksum. } }; Let's say I'd like to be able to unit test the part of this class that calculates the checksum. Unit testing the parts of the class that load in the file and such is impractical, because to test every part of the getChecksum() method I might need to construct 40 or 50 files! Now lets say I'd like to reuse the checksum method elsewhere in the class. I extract the method so that it now looks like this: class Foo { std::wstring fileName_; static int calculateChecksum(const std::vector<unsigned char> &fileBytes) { //Long method to figure out what checksum it is. } public: Foo(const std::wstring& fileName) : fileName_(fileName) { //Construct a Foo here. }; int getChecksum() { //Open the file and read some part of it return calculateChecksum( something ); } void modifyThisFileSomehow() { //Perform modification int newChecksum = calculateChecksum( something ); //Apply the newChecksum to the file } }; Now I'd like to unit test the calculateChecksum() method because it's easy to test and complicated, and I don't care about unit testing getChecksum() because it's simple and very difficult to test. But I can't test calculateChecksum() directly because it is private. Does anyone know of a solution to this problem?

    Read the article

  • How do you unit-test a method with complex input-output

    - by Dan
    When you have a simple method, like for example sum(int x, int y), it is easy to write unit tests. You can check that method will sum correctly two sample integers, for example 2 + 3 should return 5, then you will check the same for some "extraordinary" numbers, for example negative values and zero. Each of these should be separate unit test, as a single unit test should contain single assert. What do you do when you have a complex input-output? Take a Xml parser for example. You can have a single method parse(String xml) that receives the String and returns a Dom object. You can write separate tests that will check that certain text node is parsed correctly, that attributes are parsed OK, that child node belongs to parent etc. For all these I can write a simple input, for example <root><child/></root> that will be used to check parent-child relationships between nodes and so on for the rest of expectations. Now, take a look at follwing Xml: <root> <child1 attribute11="attribute 11 value" attribute12="attribute 12 value">Text 1</child1> <child2 attribute21="attribute 21 value" attribute22="attribute 22 value">Text 2</child2> </root> In order to check that method worked correctly, I need to check many complex conditions, like that attribute11 and attribute12 belong to element1, that Text 1 belongs to child1 etc. I do not want to put more than one assert in my unit-test. How can I accomplish that?

    Read the article

  • Need an advice for unit testing using mock object

    - by Andree
    Hi there, I just recently read about "Mocking objects" for unit testing and currently I'm having a difficulties implementing this approach in my application. Please let me explain my problem. I have a User model class, which is dependent on 2 data sources (database and facebook web service). The controller class simply use this User model as an interface to access data and it doesn't care about where the data came from. Currently I never done any unit test to this User model because it is dependent on an external web service. But just a while ago, I read about object mocking and now I know that it is a common approach to unit test a class that depends on external resources (like in my case). Now I want to create a unit test for the User model, but then I encountered a design issue: In order for the User model to use a mocked Facebook SDK, I have to inject this mocked Facebook SDK to the User object (probably using a setter). Therefore I can't construct the Facebook SDK inside the User object. I have to construct it outside the User object, and inject the SDK into the User object. The real client of my User model is the application's controller. Therefore I have to construct the Facebook SDK inside the controller and inject it to the user object. Well, this is a problem because I want my controller to be as clean as possible. I want my controller to be ignorant about the application's data source. I'm not good at explaining something systematically, so you'll probably sleeping before reading this last paragraph. But anyway, I want to ask if anyone here ever encountered the same problem as mine? How do you solve this problem? Regards, Andree

    Read the article

  • Memory allocation and release for UIImage in iPhone?

    - by rkbang
    Hello all, I am using following code in iPhone to get smaller cropped image as follows: - (UIImage*) getSmallImage:(UIImage*) img { CGSize size = img.size; CGFloat ratio = 0; if (size.width < size.height) { ratio = 36 / size.width; } else { ratio = 36 / size.height; } CGRect rect = CGRectMake(0.0, 0.0, ratio * size.width, ratio * size.height); UIGraphicsBeginImageContext(rect.size); [img drawInRect:rect]; UIImage *tempImg = [UIGraphicsGetImageFromCurrentImageContext() retain]; UIGraphicsEndImageContext(); return [tempImg autorelease]; } - (UIImage*)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect { //create a context to do our clipping in UIGraphicsBeginImageContext(rect.size); CGContextRef currentContext = UIGraphicsGetCurrentContext(); //create a rect with the size we want to crop the image to //the X and Y here are zero so we start at the beginning of our //newly created context CGFloat X = (imageToCrop.size.width - rect.size.width)/2; CGFloat Y = (imageToCrop.size.height - rect.size.height)/2; CGRect clippedRect = CGRectMake(X, Y, rect.size.width, rect.size.height); //CGContextClipToRect( currentContext, clippedRect); //create a rect equivalent to the full size of the image //offset the rect by the X and Y we want to start the crop //from in order to cut off anything before them CGRect drawRect = CGRectMake(0, 0, imageToCrop.size.width, imageToCrop.size.height); CGContextTranslateCTM(currentContext, 0.0, drawRect.size.height); CGContextScaleCTM(currentContext, 1.0, -1.0); //draw the image to our clipped context using our offset rect //CGContextDrawImage(currentContext, drawRect, imageToCrop.CGImage); CGImageRef tmp = CGImageCreateWithImageInRect(imageToCrop.CGImage, clippedRect); //pull the image from our cropped context UIImage *cropped = [UIImage imageWithCGImage:tmp];//UIGraphicsGetImageFromCurrentImageContext(); CGImageRelease(tmp); //pop the context to get back to the default UIGraphicsEndImageContext(); //Note: this is autoreleased*/ return cropped; } I am using following line of code in cellForRowAtIndexPath to update the image of the cell: cell.img.image = [self imageByCropping:[self getSmallImage:[UIImage imageNamed:@"goal_image.png"]] toRect:CGRectMake(0, 0, 36, 36)]; Now when I add this table view and pop it from navigation controller, I see a memory hike.I see no leaks but memory keeps climbing. Please note that the images changes for each row and I am creating the controller using lazy initialization that is I create or alloc it whenever I need it. I saw on internet many people facing the same issue, but very rare good solutions. I have multiple views using the same way and I see almost memory raised to 4MB within 20-25 view transitions. What is the good solution to resolve this issue. tnx.

    Read the article

  • Showing folder size in Windows Explorer is a missing feature in Windows 7 [closed]

    - by JamesM
    Why doesn't Microsoft implement Folder Size in the file explorer for Windows 7? When viewing a directory you get a list of files and folders. The files all show their filesize, but the folders do not. To see the folder size you have to use the tooltip, or go to File Properties. Folder Size for Windows is a project that already exists which provides an addon to do this. I cannot believe Microsoft didnt put it in Windows 7! Unless I am wrong. I am sure however, they may have a good reason for which I lack understanding.

    Read the article

  • error of pdf2djvu: "Bogus memory allocation size"

    - by Tim
    I am using pdf2djvu to convert a pdf file into a djvu file, but got this error while trying to convert to either bundled or indirect multi-page djvu file: $ pdf2djvu 1.pdf -o 1.djvu 1.pdf: - page #1 -> #1 Bogus memory allocation size $ pdf2djvu 1.pdf -i 1.djvu 1.pdf: - page #1 -> #1 Bogus memory allocation size I was wondering what is wrong here and how I shall fix the problem? You can suggest another application other than pdf2djvu. My pdf file can be downloaded from here , in case that you may wonder what is special about it. Thanks and regards!

    Read the article

  • Windows 7: How to display the total size of Recycle Bin

    - by Mehper C. Palavuzlar
    On Windows XP, the total size of Recycle Bin could be seen easily, but I can't see it on Windows 7. Why did Microsoft hide/remove this feature? Am I missing something? REMARK 1: I don't need to see the maximum size that Recyle Bin can contain. REMARK 2: Once you have several files selected in the Recycle Bin, you get a "See more details" link in the status bar, but clicking on that does not display the total file size. Microsoft has apparently changed this.

    Read the article

  • How to fix error in pdf2djvu: "Bogus memory allocation size"

    - by Tim
    I am using pdf2djvu to convert a pdf file into a djvu file, but got this error while trying to convert either bundled or indirect multi-page djvu file: $ pdf2djvu 1.pdf -o 1.djvu 1.pdf: - page #1 -> #1 Bogus memory allocation size $ pdf2djvu 1.pdf -i 1.djvu 1.pdf: - page #1 -> #1 Bogus memory allocation size I was wondering what is wrong here and how I shall fix the problem? You can suggest another application other than pdf2djvu. To convert it to djvu My pdf file can be downloaded from here , in case that you may wonder what is special about it. Thanks and regards

    Read the article

  • Manual memory allocation and purity

    - by Eonil
    Language like Haskell have concept of purity. In pure function, I can't mutate any state globally. Anyway Haskell fully abstracts memory management, so memory allocation is not a problem here. But if languages can handle memory directly like C++, it's very ambiguous to me. In these languages, memory allocation makes visible mutation. But if I treat making new object as impure action, actually, almost nothing can be pure. So purity concept becomes almost useless. How should I handle purity in languages have memory as visible global object?

    Read the article

  • wordpress makes duplicate images of different size

    - by Mark
    I have a wordpress website. I upload my pictures to the media library. And when I import a picture in a post, you get the options, one of which ask you what size to display it in. And doing this results in creating a new image file that is a different size, rather than wordpress using html to control the size of the image. The following image shows how different sized picture copies are made of the same one with different resolution. http://imgur.com/uVqTN Thank you everyone in advance.

    Read the article

  • Multiple Silverlight Unit Test Projects in Solution

    - by IUnknown
    I am building out a number of Silverlight 4.0 libraries that are part of the same solution. I like to break them into separate projects and have a Unit Test project for each: SolutionX -LibraryProject1 ---Class1.cs ---Class2.cs -LibraryProject1.Test ---Tests1.cs ---Tests2.cs -LibraryProject2 ---Class1.cs ---Class2.cs ---CLass3.cs -LibraryProject2.Test ---Tests1.cs ---Tests2.cs ---Tests3.cs -LibraryProject3 ---Class1.cs -LibraryProject3.Test ---Tests1.cs This works great when using VS regular test projects and infrastructure because I can create and execute list of test that are aggregated from each Test project. But with the Silverlight Unit Test Framework since the Silverlight Unit Test Project must be the "start up project" I cannot figure how to run a collection of tests from each test project in one go. I have to run each separately then switch the starting project each time. I would prefer to avoid create complex build scripts or build definitions - is there a way to run all the tests at once? -Thanks

    Read the article

  • Tibco Unit Testing tools

    - by mezoid
    Does anyone know what unit testing tools are available when developing Tibco processes? In the next few months I'll be working on a Tibco project and I'm trying to find any existing unit testing frameworks that might make the job easier to build with a TDD approach. Thus far, the only one I've been able to locate is called BWUnit. It seems ok but its currently in beta and its commercial software. If possible I'd like to use an open source tool but as long as it is able to do a good job I'd be happy. So does anyone know of any other unit testing tools for Tibco development?

    Read the article

  • Where to ask practical unit-testing questions?

    - by Ian Boyd
    Before i can understand unit testing, i have to see real world examples. Every book, blog, article, or answer i've seen gives hypothetical examples that don't apply to the/my real world. i really don't want to flood StackOverflow with hundreds of questions all titled "How do i unit-test this?" There must be another place i can go to ask for real solutions. Where can i go to get practical answers to unit-testing questions? Note: i would give an example question, but then people would get grumpy when i asked the 200 follow-up questions.

    Read the article

  • Good tools which generate NUnit unit tests for .NET assemblies in Visual Studio 2008

    - by andy
    Hey guys, I'm pretty new to Unit Testing so bare with me. I realize that best best practice is not to auto generate unit tests, however I'd like to use Code Generation to set-up the basic skeleton of the tests. Now, I know Visual Studio 2008 already has the built in "create tests", however, it just creates a flat list of all the classes it's going to test... and it's not for NUnit right? Ideally, I'd like the code generation to follow the folder AND namespace structure of the assembly its generating tests for. Can you guys recommend any good tools which generate NUnit unit tests for .NET assemblies in Visual Studio 2008? cheers!

    Read the article

  • Visual Studio 2010 does not discover new unit tests

    - by driis
    I am writing some unit tests in Visual Studio 2010. I can run all tests by using "Run all Tests in Current Context". However, if I write a new unit test, it does not get picked up by the environment - in other words, I am not able to find it in Test List Editor, by running all tests, or anywhere else. If I unload the project and then reload it; the new test is available to run. When I am adding a unit test, I simply add a new method to an already existing TestClass and decorating it with [TestMethod] attribute - nothing fancy. What might be causing this behaviour, and how do I make it work ?

    Read the article

  • Unit Testing, IDataContext and Stored Procedures via Linq

    - by Terry_Brown
    hey folks, I'm currently using Stephen Walther's approach to unit testing Linq to SQL and the datacontext (http://stephenwalther.com/blog/archive/2008/08/17/asp-net-mvc-tip-33-unit-test-linq-to-sql.aspx) which is working a treat for all things linq. My Dal layer takes in an IDataContext, I use DI (via Unity) to concrete that up as the correct DataContext object and all works well. But - we have a company policy here of writes going via Stored Procs. Has anyone come up with a solution for mocking/faking the data context and still allowing stored procs to effectively be unit tested? I've got no real experience of any of the mocking frameworks (Rhino etc.) so if these are the correct means of doing this, I'd love some pointers on guides for them. Many thanks, Terry

    Read the article

  • What is the current state of Unit testing support in the R language

    - by PaulHurleyuk
    R is a statistics programming language. Part of R is the use of Packages, which themselves are written in the R language. Programming best practice includes the use of unit-testing to test the functions within these packages while they are being written and when they are used. I am aware of a few packages for unit testing within R, these being RUnit Svunit Testthat I'm interested to know; Are there any other packages out there ? Given peoples experience, do these packages excel at different things ? What's the current state of the art in unit testing for R ?

    Read the article

  • Unit testing "hybrid" WPF/Silverlight controls

    - by Alan Mendelevich
    I'm starting a new WPF/Silverlight custom control project and wanted to do unit testing on this one. However I'm a little confused about how to approach this. This control would be based on the same codebase for both WPF and Silverlight with minor forking using #ifs and partial classes to tame the differences. I guess I could write unit tests for WPF part with NUnit, MSTest, xUnit, etc. and for the Silverlight part with Silverlight Unit Test Framework but this doesn't sound very elegant to me. I'd have to either ignore testing identical code on one of the platforms and test only differing parts (which is not very trustworthy) or rewrite tests for 2 frameworks (which is annoying). Is this the right way to go? I'm wondering if there's some guidance, articles, tutorials out there on how to approach this task. Any pointers?

    Read the article

  • Perl unit test - start a tcp server & continue

    - by John
    I am trying to write a unit test for a client server application. To test the client, in my unit test, I want to first start my tcp server (which itself is another perl file). I tried to start the tcp server by forking: if (! fork()) { system ("$^X server.pl") == 0 or die "couldn't start server" } So when I call "make test" after "perl Makefile.PL", this test starts & I can see the server starting but after that the unit test just hangs there. So I guess I need to start this server in background and I tried the "&" at the end to force it to start in background & then test to continue. But, I still couldn't succeed. What am I doing wrong? Thanks.

    Read the article

  • Unit testing custom controls in Silverlight

    - by Hrvoje
    I have several custom controls (some kind of frames for content and layout management, like wrap panel), and would like to write unit tests for them. It's hard to find any good examples except Silverlight control toolkit, which has some helper classes to do unit tests and it's quite complicated. For MVVM classes it's easy to write tests because they don't use SL dependency system and infrastructure. Questions: how to unit test DepedenyProperty, what do I need to test how to test attached property do I test bindings with theme or UserControl, like simple textblock content binding, or command/event binding in MVVM with UserControl what else do I test in my custom controls, beside my business logic any good tutorial to achieve tests like those in control toolkit How do I start? Is SL controls toolkit only option for learning? For testing framework i'm using one from control toolkit, and for continuus integration on TFS build server I planned to use Statlight (from codeplex). Any advice on that?

    Read the article

  • IronPython For Unit Testing over C#

    - by Krish
    We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. Is it ideal choice to write unit test cases in IronPython instead of C#? Any body has done like that? I wrote few test cases, they seems to be good. But hairy pointy managers won't accept.

    Read the article

  • Maximum File Size and Pixels for Uploaded Business Documents

    - by webdevguy
    I am creating a php form that accepts an upload of business documents in a variety of formats .pdf, .doc, .tiff, .jpeg, etc. and I need to restrict the size of the files that are uploaded. It's trivial for me to restrict the file size, but I'm not sure if I should also restrict the max height/width, which are also available options. I will need to occasionally print these documents to 8.5 X 11inch paper and have them be legible, but don't really care if images come out. Should I restrict the pixels sizes or is that redundant with restricting the file size? If so, do you guys have a recommendations for max height/width for, say, a 5MB file size limit? I really have no idea what the relationship between pixel size and image size is or what the common pixel sizes are for scanned images. Also, what would be a reasonable size expectation for a legible print per page?

    Read the article

  • unit-testing maven plugins

    - by Don
    Hi, I'm looking for information about how to write unit tests for Maven plugins. Although there's a page on the Maven site about this topic, there's only one example unit test, which does nothing useful. I also found this wiki page, but it hasn't been updated for more than 4 years, so I'm reluctant to invest any faith in it. I checked the book "The Definitive Guide to Maven", but it doesn't even mention the subject. I'd like to write my unit tests in either Groovy or Java, and would appreciate any information about how to do this. Thanks, Don

    Read the article

  • Unit testing huge applications - Proven methodologies?

    - by NLV
    Hello members I've been working in windows forms applications and ASP.Net applications for the past 10 months. I've always wondered how to perform proper unit testing on the complete application in a robust manner covering all the scenarios. I've the following questions regarding them - What are the standard mechanisms in performing unit testing and writing test cases? Does the methodologies change based on the application nature such as Windows Forms, Web applications etc? What is the best approach to make sure we cover all the scenarios? Any popular books on this? Popular tools for performing unit testing?

    Read the article

  • Why is unit testing needed in iPhone / iPad ?

    - by Madhup
    Hi, I am developing an application for iPad application. I need to perform unit testing in the application. But I am not sure why I should do unit testing in this application. The applications in these environments are rather small for unit testing to be written. And since the iPhone sentestingkit is not well documented the implementation and wriiting test cases is so time consuming. So why should we waste time in this? And if we have to what should be the best approach to write test cases? Thanks, Madhup

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >