Skip to content

Commit

Permalink
Fixing directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
richardroberts committed Aug 21, 2009
0 parents commit d80fa24
Show file tree
Hide file tree
Showing 163 changed files with 20,617 additions and 0 deletions.
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Frank Dellaert
Christian Potthast
Alireza Fathi
Carlos Nieto
3 changes: 3 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The GTSAM library is not (yet) open source: the software was created
by Frank Dellaert and his students, but the copyright is legally owned
by the Georgia Board Of Regents.
50 changes: 50 additions & 0 deletions CppUnitLite/Failure.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@


#include "Failure.h"

#include <stdio.h>
#include <string.h>


Failure::Failure (const SimpleString& theTestName,
const SimpleString& theFileName,
long theLineNumber,
const SimpleString& theCondition)
: message (theCondition),
testName (theTestName),
fileName (theFileName),
lineNumber (theLineNumber)
{
}


Failure::Failure (const SimpleString& theTestName,
const SimpleString& theFileName,
long theLineNumber,
const SimpleString& expected,
const SimpleString& actual)
: testName (theTestName),
fileName (theFileName),
lineNumber (theLineNumber)
{
char *part1 = "expected ";
char *part3 = " but was: ";

char *stage = new char [strlen (part1)
+ expected.size ()
+ strlen (part3)
+ actual.size ()
+ 1];

sprintf(stage, "%s%s%s%s",
part1,
expected.asCharString(),
part3,
actual.asCharString());

message = SimpleString(stage);

delete stage;
}


41 changes: 41 additions & 0 deletions CppUnitLite/Failure.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

///////////////////////////////////////////////////////////////////////////////
//
// FAILURE.H
//
// Failure is a class which holds information pertaining to a specific
// test failure. The stream insertion operator is overloaded to allow easy
// display.
//
///////////////////////////////////////////////////////////////////////////////


#ifndef FAILURE_H
#define FAILURE_H

#include "SimpleString.h"


class Failure
{

public:
Failure (const SimpleString& theTestName,
const SimpleString& theFileName,
long theLineNumber,
const SimpleString& theCondition);

Failure (const SimpleString& theTestName,
const SimpleString& theFileName,
long theLineNumber,
const SimpleString& expected,
const SimpleString& actual);

SimpleString message;
SimpleString testName;
SimpleString fileName;
long lineNumber;
};


#endif
29 changes: 29 additions & 0 deletions CppUnitLite/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Makefile to compile the unit test library, will end up in $(LIBDIR)

.PHONY: all install clean

all: libCppUnitLite.a

CC=gcc
CXX=gcc
CPP=gcc
CXXFLAGS += -O2

sources = $(shell ls *.cpp)
objects = $(sources:.cpp=.o)

library = libCppUnitLite.a

$(library): $(objects)
ar crsv $@ $(objects)
ranlib $(library)

clean:
rm -f *.o *.*~ $(library)

check:
echo 'no check for CppUnitLite'

distdir:

install:
95 changes: 95 additions & 0 deletions CppUnitLite/SimpleString.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@


#include "SimpleString.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>


static const int DEFAULT_SIZE = 20;

SimpleString::SimpleString ()
: buffer(new char [1])
{
buffer [0] = '\0';
}


SimpleString::SimpleString (const char *otherBuffer)
: buffer (new char [strlen (otherBuffer) + 1])
{
strcpy (buffer, otherBuffer);
}

SimpleString::SimpleString (const SimpleString& other)
{
buffer = new char [other.size() + 1];
strcpy(buffer, other.buffer);
}


SimpleString SimpleString::operator= (const SimpleString& other)
{
delete buffer;
buffer = new char [other.size() + 1];
strcpy(buffer, other.buffer);
return *this;
}


char *SimpleString::asCharString () const
{
return buffer;
}

int SimpleString::size() const
{
return strlen (buffer);
}

SimpleString::~SimpleString ()
{
delete [] buffer;
}


bool operator== (const SimpleString& left, const SimpleString& right)
{
return !strcmp (left.asCharString (), right.asCharString ());
}


SimpleString StringFrom (bool value)
{
char buffer [sizeof ("false") + 1];
sprintf (buffer, "%s", value ? "true" : "false");
return SimpleString(buffer);
}

SimpleString StringFrom (const char *value)
{
return SimpleString(value);
}

SimpleString StringFrom (long value)
{
char buffer [DEFAULT_SIZE];
sprintf (buffer, "%ld", value);

return SimpleString(buffer);
}

SimpleString StringFrom (double value)
{
char buffer [DEFAULT_SIZE];
sprintf (buffer, "%lf", value);

return SimpleString(buffer);
}

SimpleString StringFrom (const SimpleString& value)
{
return SimpleString(value);
}


45 changes: 45 additions & 0 deletions CppUnitLite/SimpleString.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

///////////////////////////////////////////////////////////////////////////////
//
// SIMPLESTRING.H
//
// One of the design goals of CppUnitLite is to compilation with very old C++
// compilers. For that reason, I've added a simple string class that provides
// only the operations needed in CppUnitLite.
//
///////////////////////////////////////////////////////////////////////////////

#ifndef SIMPLE_STRING
#define SIMPLE_STRING



class SimpleString
{
friend bool operator== (const SimpleString& left, const SimpleString& right);

public:
SimpleString ();
SimpleString (const char *value);
SimpleString (const SimpleString& other);
~SimpleString ();

SimpleString operator= (const SimpleString& other);

char *asCharString () const;
int size() const;

private:
char *buffer;
};



SimpleString StringFrom (bool value);
SimpleString StringFrom (const char *value);
SimpleString StringFrom (long value);
SimpleString StringFrom (double value);
SimpleString StringFrom (const SimpleString& other);


#endif
59 changes: 59 additions & 0 deletions CppUnitLite/Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@


#include "Test.h"
#include "TestRegistry.h"
#include "TestResult.h"
#include "Failure.h"


Test::Test (const SimpleString& testName)
: name_ (testName)
{
TestRegistry::addTest (this);
}



Test *Test::getNext() const
{
return next_;
}

void Test::setNext(Test *test)
{
next_ = test;
}

bool Test::check(long expected, long actual, TestResult& result, const SimpleString& fileName, long lineNumber)
{
if (expected == actual)
return true;
result.addFailure (
Failure (
name_,
StringFrom (__FILE__),
__LINE__,
StringFrom (expected),
StringFrom (actual)));

return false;

}


bool Test::check(const SimpleString& expected, const SimpleString& actual, TestResult& result, const SimpleString& fileName, long lineNumber)
{
if (expected == actual)
return true;
result.addFailure (
Failure (
name_,
StringFrom (__FILE__),
__LINE__,
expected,
actual));

return false;

}

Loading

0 comments on commit d80fa24

Please sign in to comment.