[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paragui-cvs] CVS: paragui/src/libsigc++/tests Makefile.am,NONE,1.1.2.1
From: |
Alexander Pipelka <address@hidden> |
Subject: |
[paragui-cvs] CVS: paragui/src/libsigc++/tests Makefile.am,NONE,1.1.2.1 README,NONE,1.1.2.1 bind_return_test.cc,NONE,1.1.2.1 bind_test.cc,NONE,1.1.2.1 class_slot_test.cc,NONE,1.1.2.1 connection_test.cc,NONE,1.1.2.1disappearing_observer_test.cc,NONE,1.1.2.1 hide_test.cc,NONE,1.1.2.1 method_slot_test.cc,NONE,1.1.2.1 object_slot_test.cc,NONE,1.1.2.1 object_test.cc,NONE,1.1.2.1 retype_return_test.cc,NONE,1.1.2.1 retype_test.cc,NONE,1.1.2.1 size_test.cc,NONE,1.1.2.1 slot_test.cc,NONE,1.1.2.1 |
Date: |
Mon, 03 Feb 2003 19:08:19 -0500 |
Update of /cvsroot/paragui/paragui/src/libsigc++/tests
In directory subversions:/tmp/cvs-serv19686/src/libsigc++/tests
Added Files:
Tag: devel-opengl
Makefile.am README bind_return_test.cc bind_test.cc
class_slot_test.cc connection_test.cc
disappearing_observer_test.cc hide_test.cc method_slot_test.cc
object_slot_test.cc object_test.cc retype_return_test.cc
retype_test.cc size_test.cc slot_test.cc
Log Message:
added libsigc++ 1.2.3 (building statically linked versions, Win32)
physfs autoconf / automake fixes
--- NEW FILE ---
# Ovveride DEFS and DEFAULT_INCLUDES to suppress "-I. -I$(srcdir)"
DEFS = @DEFS@
DEFAULT_INCLUDES =
INCLUDES = -I$(top_builddir) -I$(top_srcdir) -I$(top_builddir)/sigc++/config
LDADD = $(top_builddir)/sigc++/libsigc-1.2.la
noinst_PROGRAMS = \
size_test connection_test object_test \
slot_test object_slot_test class_slot_test \
bind_test bind_return_test \
retype_test retype_return_test hide_test \
method_slot_test disappearing_observer_test
TESTS = \
bind_return_test bind_test class_slot_test \
connection_test \
hide_test object_slot_test object_test retype_test \
retype_return_test size_test slot_test method_slot_test \
disappearing_observer_test
#
# Component tests
size_test_SOURCES = size_test.cc
connection_test_SOURCES = connection_test.cc
object_test_SOURCES = object_test.cc
#
# Slot tests
slot_test_SOURCES = slot_test.cc
object_slot_test_SOURCES = object_slot_test.cc
method_slot_test_SOURCES = method_slot_test.cc
class_slot_test_SOURCES = class_slot_test.cc
#array_test_SOURCES = array_test.cc
#
# Signal tests
#basic_SOURCES = basic.cc
#vbasic_SOURCES = vbasic.cc
#disconnect_SOURCES = disconnect.cc
#
# Adaptor tests
bind_test_SOURCES = bind_test.cc
bind_return_test_SOURCES = bind_return_test.cc
retype_test_SOURCES = retype_test.cc
retype_return_test_SOURCES = retype_return_test.cc
hide_test_SOURCES = hide_test.cc
#
# Runtime tests
disappearing_observer_test_SOURCES = disappearing_observer_test.cc
#
# Size target - used in benchmarking improvements
size:
rm -f size
make clean
make all
echo "Unstriped tests:" > size
ls -l .libs/* | awk '{print substr($$0,35,8),substr($$0,63);}' >> size
echo "Striped tests:" >> size
strip .libs/*
ls -l .libs/* | awk '{print substr($$0,35,8),substr($$0,63);}' >> size
--- NEW FILE ---
All tests in this directory demonstrate various aspects of the
tool. All tests are assigned to the public domain.
To test to library, run a "make check" in this directory.
Passing for most tests is compiling. To verify the output,
each test records its actions and tests that a numerical result
from those actions is correct. If a test is not passed in
your install, please report it to the mailing list.
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/bind_return.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
void foo() { }
int main()
{
int result;
cout << ">>test 1"<<endl;
Slot0<int> s=bind_return(slot(&foo),42);
cout << (result=s()) << endl;
return !(result==42);
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/bind.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
int result=1;
struct A
{
A() { cout << "A()"<<endl;}
A(int) { cout << "A(int)" <<endl;}
A(const A&) { cout << "A(const A&)"<<endl;}
~A() { cout << "~A()"<<endl;}
};
void foo(int i) { cout << "foo("<< i << ")" <<endl; result+=5;}
void foo2(A) { cout << "foo2(A)" <<endl; result+=3;}
int main()
{
cout << ">>test 1"<<endl;
Slot0<void> s=bind(slot(&foo),1);
s();
cout << ">>test 2"<<endl;
s=bind(slot(&foo2),1);
s();
cout << ">>test 3"<<endl;
s.clear();
cout << ">>end"<<endl;
return !(result==9);
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/class_slot.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
int result=1;
class Foo
{
int i;
public:
void foo()
{
cout << "hello "<<i <<endl; result+=3;
}
void foo2()
{
cout << "there "<<i <<endl; result+=5;
}
Foo() : i(1) {}
};
int main()
{
Foo f;
Slot0<void> s;
cout << ">> call nothing connected" <<endl;
s();
cout << ">> call with foo" <<endl;
s=slot_class(f,&Foo::foo);
s();
cout << ">> call with foo2" <<endl;
s=slot_class(f,&Foo::foo2);
s();
cout << ">> call after clear" <<endl;
s.clear();
s();
return !(result==9);
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/connection.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
class TestConnectionNode: public ConnectionNode
{
public:
TestConnectionNode(SlotNode* s): ConnectionNode(s) {}
~TestConnectionNode() { cout << "~ConnectionNode" <<endl; }
};
void foo()
{}
int main()
{
bool correct;
// create internals which we can control
SlotNode* s=new FuncSlotNode((FuncPtr)&foo,(FuncPtr)&foo);
ConnectionNode *node=new TestConnectionNode(s);
Connection c1,c2,c3;
c1=Connection(node);
c2=Connection(node);
c3=Connection(node);
correct=c1&&c2&&c3;
cout << bool(c1) << bool(c2) << bool(c3) <<endl;
c2.clear();
correct|=c1&&!c2&&c3;
cout << bool(c1) << bool(c2) << bool(c3) <<endl;
c2=Connection(node);
c1.disconnect();
correct|=!c1&&!c2&&!c3;
cout << bool(c1) << bool(c2) << bool(c3) <<endl;
return !correct;
}
--- NEW FILE ---
#include <sigc++/sigc++.h>
/// This class emits a signal in its destructor
struct foo
{
~foo() { signal.emit(); }
SigC::Signal0<void> signal;
};
/// This class deletes itself when it receives a signal
struct bar :
public SigC::Object
{
bar(foo& Foo)
{
Foo.signal.connect(SigC::slot(*this, &bar::closed));
}
void closed()
{
delete this;
}
};
int main(int, char**)
{
foo f;
new bar(f);
return 0;
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/hide.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
int result=1;
void foo() { cout << "foo()" <<endl; result+=3;}
void foo2(int) { cout << "foo2()" <<endl; result+=5;}
int main()
{
cout << ">>test 1"<<endl;
Slot2<void,int,float> s=hide<int,float>(slot(&foo));
s(1,1);
cout << ">>test 2"<<endl;
s=hide<float>(slot(&foo2));
s(1,1);
cout << ">>end"<<endl;
return !(result==9);
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/method_slot.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
int result=1;
class Foo
{
int i;
public:
void foo()
{
cout << "hello "<<i <<endl; result+=3;
}
void foo2()
{
cout << "there "<<i <<endl; result+=5;
}
void foo_const() const
{
cout << "hello "<<i <<endl; result+=7;
}
void foo2_const() const
{
cout << "there "<<i <<endl; result+=11;
}
Foo() : i(1) {}
~Foo()
{ cout << "~Foo()"<<endl; }
};
int main()
{
cout << ">> test 1 (assignment to members)" << endl;
{
Foo f;
Slot1<void,Foo&> s;
cout << " call nothing connected" <<endl;
s(f);
cout << " call with foo" <<endl;
s = slot(&Foo::foo);
s(f);
cout << " call with foo2" <<endl;
s = slot(&Foo::foo2);
s(f);
cout << " call after clear" <<endl;
s.clear();
}
cout << ">> test 2 (assignment to members const)" << endl;
{
Foo f;
Slot1<void,const Foo&> s;
cout << " call nothing connected" <<endl;
s(f);
cout << " call with foo" <<endl;
s = slot(&Foo::foo_const);
s(f);
cout << " call with foo2" <<endl;
s = slot(&Foo::foo2_const);
s(f);
cout << " call after clear" <<endl;
s.clear();
s(f);
}
cout<< result <<endl;
return !(result==27);
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/object_slot.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
int result=1;
class Foo : public Object
{
int i;
public:
void foo()
{
cout << "hello "<<i <<endl; result+=3;
}
void foo2()
{
cout << "there "<<i <<endl; result+=5;
}
Foo() : i(1) {}
~Foo()
{ cout << "~Foo()"<<endl; }
};
// has no knowledge of sigc++ so doesn't derive from Object
class A
{
public:
int i,j;
void foo() { cout << "A::foo" <<endl; result+=7; }
};
// later a user wants to use slots so they add Object to give lifetime safety
class B : public A, public Object
{
};
int main()
{
cout << ">> test 1 (assignment to members)" << endl;
{
Foo f;
Slot0<void> s;
cout << " call nothing connected" <<endl;
s();
cout << " call with foo" <<endl;
s = slot(f, &Foo::foo);
s();
cout << " call with foo2" <<endl;
s = slot(f, &Foo::foo2);
s();
cout << " call after clear" <<endl;
s.clear();
s();
}
{
cout << "\n>> test 2 (call after destruction)" << endl;
Slot0<void> s;
{
Foo f;
cout << " call within scope" <<endl;
s=slot(f, &Foo::foo);
s();
}
cout << " call out of scope" <<endl;
s();
}
cout << "\n>> test 3 using derived classes to add lifetime"<<endl;
{
// sigc++ 1.0 failed this.
B b;
Slot0<void> s = slot(b, &A::foo);
s();
}
return !(result==19);
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/object.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
class Foo : public Object
{
public:
static bool alive;
Foo()
{ cout << "Foo()" <<endl; alive=true;}
~Foo()
{ cout << "~Foo()" <<endl; alive=false;}
};
bool Foo::alive;
int main()
{
bool fail=false;
cout << ">> test 1 (containment)" <<endl;
{
Ptr<Foo> f=manage(new Foo());
fail|=!Foo::alive;
}
fail|=Foo::alive;
cout << "\n>> test 2 (extend)" <<endl;
{
Ptr<Foo> f2;
{
Ptr<Foo> f=manage(new Foo());
f2=f;
fail|=!Foo::alive;
}
cout << "(extend)" << endl;
fail|=!Foo::alive;
}
fail|=Foo::alive;
cout << "\n>> test 3 (destruction)" <<endl;
{
Ptr<Foo> f=manage(new Foo());
cout << (Foo*)f << endl;
delete f;
fail|=Foo::alive;
cout << (Foo*)f << endl;
}
fail|=Foo::alive;
cout << "\n>> test 4 (self assign)" <<endl;
{
Ptr<Foo> f=manage(new Foo());
f=f;
fail|=!Foo::alive;
cout << (Foo*)f << endl;
}
fail|=Foo::alive;
return fail;
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/retype_return.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
int result=1;
float foo() { cout << "foo()" <<endl; result+=3; return 4.0; }
int main()
{
cout << ">>test 1"<<endl;
Slot0<int> s=retype_return<int>(slot(&foo));
cout << (result+=s()) <<endl;
cout << ">>test 2"<<endl;
Slot0<void> s2=retype_return<void>(slot(&foo));
s2();
return !(result==11);
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/retype.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
int result=1;
float foo(float i, float j)
{
result+=int (i*j);
return i*j;
}
int main()
{
cout << ">>test 1"<<endl;
Slot2<int,int,int> s=retype<int,int,int>(slot(&foo));
cout << s(4,5)<<endl;
cout << ">>test 2"<<endl;
Slot2<void,double,int> s2=retype<void,double,int>(slot(&foo));
s2(1,2);
return !(result==23);
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/connection.h>
#include <sigc++/slot.h>
#include <sigc++/object.h>
#include <sigc++/object_slot.h>
#include <sigc++/class_slot.h>
#include <sigc++/signal.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
int main()
{
cout << "Public classes:" << endl
<< " Connection " << sizeof(Connection) << endl
<< " Object " << sizeof(Object) << endl
<< " SlotBase " << sizeof(SlotBase) << endl
<< " SignalBase " << sizeof(SignalBase) << endl
<< " ObjectBase " << sizeof(ObjectBase) << endl
<< endl
<< "Internal classes:" << endl
<< " Control_ " << sizeof(Control_) << endl
<< " BaseNode " << sizeof(NodeBase) << endl
<< " SlotNode " << sizeof(SlotNode) << endl
<< " FuncSlotNode " << sizeof(FuncSlotNode) << endl
<< " ConnectionNode " << sizeof(ConnectionNode) << endl
<< " ObjectSlotNode " << sizeof(ObjectSlotNode) << endl
<< " ClassSlotNode " << sizeof(ClassSlotNode) << endl
<< " SignalNode " << sizeof(SignalNode) << endl
<< " SignalConnectionNode " << sizeof(SignalConnectionNode) << endl;
return 0; // compile is passing
}
--- NEW FILE ---
// Copyright 2001 Karl Einar Nelson
#include <iostream>
#include <sigc++/slot.h>
#ifdef SIGC_CXX_NAMESPACES
using namespace std;
using namespace SigC;
#endif
int result=1;
void foo()
{
cout << "hello" <<endl; result+=3;
}
void foo2()
{
cout << "there" <<endl; result+=5;
}
int main()
{
Slot0<void> s;
cout << ">> call nothing connected" <<endl;
s();
cout << ">> call with foo" <<endl;
s=&foo;
s();
cout << ">> call with foo2" <<endl;
s=&foo2;
s();
cout << ">> call after clear" <<endl;
s.clear();
s();
return !(result==9);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paragui-cvs] CVS: paragui/src/libsigc++/tests Makefile.am,NONE,1.1.2.1 README,NONE,1.1.2.1 bind_return_test.cc,NONE,1.1.2.1 bind_test.cc,NONE,1.1.2.1 class_slot_test.cc,NONE,1.1.2.1 connection_test.cc,NONE,1.1.2.1disappearing_observer_test.cc,NONE,1.1.2.1 hide_test.cc,NONE,1.1.2.1 method_slot_test.cc,NONE,1.1.2.1 object_slot_test.cc,NONE,1.1.2.1 object_test.cc,NONE,1.1.2.1 retype_return_test.cc,NONE,1.1.2.1 retype_test.cc,NONE,1.1.2.1 size_test.cc,NONE,1.1.2.1 slot_test.cc,NONE,1.1.2.1,
Alexander Pipelka <address@hidden> <=
- Prev by Date:
[paragui-cvs] CVS: paragui autogen.sh,1.2.2.4,1.2.2.5 configure.in,1.8.2.13,1.8.2.14
- Next by Date:
[paragui-cvs] CVS: paragui/src/libsigc++/scripts Makefile.am,NONE,1.1.2.1 README,NONE,1.1.2.1 examples.Makefile,NONE,1.1.2.1 sun.m4,NONE,1.1.2.1 tests.Makefile,NONE,1.1.2.1
- Previous by thread:
[paragui-cvs] CVS: paragui autogen.sh,1.2.2.4,1.2.2.5 configure.in,1.8.2.13,1.8.2.14
- Next by thread:
[paragui-cvs] CVS: paragui/src/libsigc++/scripts Makefile.am,NONE,1.1.2.1 README,NONE,1.1.2.1 examples.Makefile,NONE,1.1.2.1 sun.m4,NONE,1.1.2.1 tests.Makefile,NONE,1.1.2.1
- Index(es):