Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jonstewart committed Jan 4, 2010
0 parents commit a821d33
Show file tree
Hide file tree
Showing 9 changed files with 700 additions and 0 deletions.
23 changes: 23 additions & 0 deletions License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
38 changes: 38 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
� 2009, Jon Stewart

Scope is a simple, lightweight unit testing framework for C++.

It should be easy to create tests, so it's important for Scope to scale down
when required. C++ is also a notoriously arcane language, with lots of gotchas.
Scope should avoid most of them, and give you a heads up about the ones you
could run into when using it. It should also adhere to as many of the C++ idioms
as possible, rather than copying idioms from other languages which aren't a good
fit in C++.

In Scope, tests are free functions. Macros are used to auto-register them, and
there's no need to register sets of tests in some other source file. When setup
and teardown functionality is needed, macros allow the test writer to specify
the type of an object, which is then created immediately before the test is run,
passed to it as a parameter, and destroyed immediately after the test runs, i.e.
Scope uses constructors and destructors instead of separate setup() and
teardown() functions.

Scope's autoregistration system does use a bunch of static variables, as well as
a static singleton to collect them, but it avoids many of the pitfalls inherit
with singletons and static allocation in C++. In particular, it does not depend
on the order of construction (or guarantees it using a Meyers singleton) and it
does not use heap-allocated memory (i.e. no calls to new or malloc() before
main()) in accordance with the standard. Among other things, this makes leak-
detectors much easier to use, since Scope shouldn't generate any noise.

Tests are organized into sets, but sets can be relational, not just
hierarchical--Scope uses a graph to represent the connections between sets and
tests. One set per source file is automatically created, and each test is put
into its corresponding source set automatically, giving you a hierarchical
structure out of the box. However, it's possible to specify that a test should
belong to other sets.

Scope needs more work with respect to command-line features, friendly output,
and performance profiling.

Scope is released under the Boost license. See License.txt for details.
17 changes: 17 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2009, Jon Stewart
# Released under the terms of the Boost license (http://www.boost.org/LICENSE_1_0.txt). See License.txt for details.

import os
import glob

def getVar(name, defaultLoc):
try:
var = os.environ[name]
return var
except:
print(' * You need to set the %s environment variable' % name)
print(' e.g. export %s=%s' % (name, defaultLoc))
sys.exit()

env = Environment(ENV = os.environ, CPPPATH = [getVar('BOOST_HOME', '~/software/boost_1_38_0')], CCFLAGS = '-Wall -Wextra')
env.Command('dummy', env.Program('test', glob.glob('*.cpp')), './$SOURCE')
12 changes: 12 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
© 2009, Jon Stewart
Released under the terms of the Boost license (http://www.boost.org/LICENSE_1_0.txt). See License.txt for details.
*/

#include <iostream>

#include "scope/testrunner.h"

int main(int argc, char *argv[]) {
return scope::DefaultRun(std::cout, argc, argv) ? 0: 1;
}
Loading

0 comments on commit a821d33

Please sign in to comment.