The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
A couple more unit testing strategies (for C extension writers)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
A couple more unit testing strategies (for C extension writers) Posted: Sep 16, 2005 1:32 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: A couple more unit testing strategies (for C extension writers)
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
In the last couple months that, when dealing with C extensions, it's best to put two more types of tests in your test suite.

First, make sure you're not modifying the receiver when you're not supposed to:
var = "hello"
assert_nothing_raised{ some_method(var) }
assert_equal("hello", var)

I was burned by this recently. I'm going to make this a regular habit, though I think it's safe to say that it's only worrisome for strings.

Second, run a tight loop with lots of iterations to check for potential memory leaks/segfaults:
1000.times{ assert_nothing_raised{ some_method }

I've caught one or two nasty bugs with this, where things seemed completely fine with a once-over, but started failing under heavier load. I suppose this could be problematic if your overall time to run the test suite starts to get outrageous.

That is all.

Read: A couple more unit testing strategies (for C extension writers)

Topic: Caught in My Filters: Poignant PDF, Korean Previous Topic   Next Topic Topic: Meta du jour

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use