Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Eric Fossum
emc1072
Commits
421a4a62
Commit
421a4a62
authored
Feb 13, 2017
by
Eric Fossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests, but they fail.
parent
6da919d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
16 deletions
+107
-16
nbproject/Makefile-Debug.mk
nbproject/Makefile-Debug.mk
+12
-5
nbproject/Makefile-Release.mk
nbproject/Makefile-Release.mk
+12
-5
nbproject/configurations.xml
nbproject/configurations.xml
+11
-6
tests/linuxi2ctest.cpp
tests/linuxi2ctest.cpp
+72
-0
No files found.
nbproject/Makefile-Debug.mk
View file @
421a4a62
...
...
@@ -42,10 +42,11 @@ TESTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tests
# Test Files
TESTFILES
=
\
${TESTDIR}
/TestFiles/f
1
${TESTDIR}
/TestFiles/f
2
# Test Object Files
TESTOBJECTFILES
=
TESTOBJECTFILES
=
\
${TESTDIR}
/tests/linuxi2ctest.o
# C Compiler Flags
CFLAGS
=
...
...
@@ -83,9 +84,15 @@ ${OBJECTDIR}/src/linux-i2c.o: src/linux-i2c.cpp
.build-tests-conf
:
.build-tests-subprojects .build-conf ${TESTFILES}
.build-tests-subprojects
:
${TESTDIR}/TestFiles/f
1
:
${OBJECTFILES:%.o=%_nomain.o}
${TESTDIR}/TestFiles/f
2
:
${TESTDIR}/tests/linuxi2ctest.o
${OBJECTFILES:%.o=%_nomain.o}
${MKDIR}
-p
${TESTDIR}
/TestFiles
${LINK.cc}
-o
${TESTDIR}
/TestFiles/f1
$^
${LDLIBSOPTIONS}
${LINK.cc}
-o
${TESTDIR}
/TestFiles/f2
$^
${LDLIBSOPTIONS}
${TESTDIR}/tests/linuxi2ctest.o
:
tests/linuxi2ctest.cpp
${MKDIR}
-p
${TESTDIR}
/tests
${RM}
"
$@
.d"
$(COMPILE.cc)
-g
-Iinclude
-I
.
-std
=
c++98
-MMD
-MP
-MF
"
$@
.d"
-o
${TESTDIR}
/tests/linuxi2ctest.o tests/linuxi2ctest.cpp
${OBJECTDIR}/src/linux-i2c_nomain.o
:
${OBJECTDIR}/src/linux-i2c.o src/linux-i2c.cpp
...
...
@@ -105,7 +112,7 @@ ${OBJECTDIR}/src/linux-i2c_nomain.o: ${OBJECTDIR}/src/linux-i2c.o src/linux-i2c.
.test-conf
:
@
if
[
"
${TEST}
"
=
""
]
;
\
then
\
${TESTDIR}
/TestFiles/f
1
||
true
;
\
${TESTDIR}
/TestFiles/f
2
||
true
;
\
else
\
./
${TEST}
||
true
;
\
fi
...
...
nbproject/Makefile-Release.mk
View file @
421a4a62
...
...
@@ -42,10 +42,11 @@ TESTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tests
# Test Files
TESTFILES
=
\
${TESTDIR}
/TestFiles/f
1
${TESTDIR}
/TestFiles/f
2
# Test Object Files
TESTOBJECTFILES
=
TESTOBJECTFILES
=
\
${TESTDIR}
/tests/linuxi2ctest.o
# C Compiler Flags
CFLAGS
=
...
...
@@ -83,9 +84,15 @@ ${OBJECTDIR}/src/linux-i2c.o: src/linux-i2c.cpp
.build-tests-conf
:
.build-tests-subprojects .build-conf ${TESTFILES}
.build-tests-subprojects
:
${TESTDIR}/TestFiles/f
1
:
${OBJECTFILES:%.o=%_nomain.o}
${TESTDIR}/TestFiles/f
2
:
${TESTDIR}/tests/linuxi2ctest.o
${OBJECTFILES:%.o=%_nomain.o}
${MKDIR}
-p
${TESTDIR}
/TestFiles
${LINK.cc}
-o
${TESTDIR}
/TestFiles/f1
$^
${LDLIBSOPTIONS}
${LINK.cc}
-o
${TESTDIR}
/TestFiles/f2
$^
${LDLIBSOPTIONS}
${TESTDIR}/tests/linuxi2ctest.o
:
tests/linuxi2ctest.cpp
${MKDIR}
-p
${TESTDIR}
/tests
${RM}
"
$@
.d"
$(COMPILE.cc)
-O2
-I
.
-MMD
-MP
-MF
"
$@
.d"
-o
${TESTDIR}
/tests/linuxi2ctest.o tests/linuxi2ctest.cpp
${OBJECTDIR}/src/linux-i2c_nomain.o
:
${OBJECTDIR}/src/linux-i2c.o src/linux-i2c.cpp
...
...
@@ -105,7 +112,7 @@ ${OBJECTDIR}/src/linux-i2c_nomain.o: ${OBJECTDIR}/src/linux-i2c.o src/linux-i2c.
.test-conf
:
@
if
[
"
${TEST}
"
=
""
]
;
\
then
\
${TESTDIR}
/TestFiles/f
1
||
true
;
\
${TESTDIR}
/TestFiles/f
2
||
true
;
\
else
\
./
${TEST}
||
true
;
\
fi
...
...
nbproject/configurations.xml
View file @
421a4a62
...
...
@@ -20,10 +20,11 @@
displayName=
"Test Files"
projectFiles=
"false"
kind=
"TEST_LOGICAL_FOLDER"
>
<logicalFolder
name=
"f
1
"
displayName=
"
C++ Simple
Test"
<logicalFolder
name=
"f
2
"
displayName=
"
Linux I2C
Test"
projectFiles=
"true"
kind=
"TEST"
>
<itemPath>
tests/linuxi2ctest.cpp
</itemPath>
</logicalFolder>
</logicalFolder>
<logicalFolder
name=
"ExternalFiles"
...
...
@@ -59,7 +60,7 @@
<commandLine>
-v
</commandLine>
</linkerTool>
</compileType>
<folder
path=
"TestFiles/f
1
"
>
<folder
path=
"TestFiles/f
2
"
>
<cTool>
<incDir>
<pElem>
.
</pElem>
...
...
@@ -71,7 +72,7 @@
</incDir>
</ccTool>
<linkerTool>
<output>
${TESTDIR}/TestFiles/f
1
</output>
<output>
${TESTDIR}/TestFiles/f
2
</output>
</linkerTool>
</folder>
<item
path=
"include/I2cBase.h"
ex=
"false"
tool=
"3"
flavor2=
"0"
>
...
...
@@ -80,6 +81,8 @@
</item>
<item
path=
"src/linux-i2c.cpp"
ex=
"false"
tool=
"1"
flavor2=
"0"
>
</item>
<item
path=
"tests/linuxi2ctest.cpp"
ex=
"false"
tool=
"1"
flavor2=
"0"
>
</item>
</conf>
<conf
name=
"Release"
type=
"2"
>
<toolsSet>
...
...
@@ -101,7 +104,7 @@
<developmentMode>
5
</developmentMode>
</asmTool>
</compileType>
<folder
path=
"TestFiles/f
1
"
>
<folder
path=
"TestFiles/f
2
"
>
<cTool>
<incDir>
<pElem>
.
</pElem>
...
...
@@ -113,7 +116,7 @@
</incDir>
</ccTool>
<linkerTool>
<output>
${TESTDIR}/TestFiles/f
1
</output>
<output>
${TESTDIR}/TestFiles/f
2
</output>
</linkerTool>
</folder>
<item
path=
"include/I2cBase.h"
ex=
"false"
tool=
"3"
flavor2=
"0"
>
...
...
@@ -122,6 +125,8 @@
</item>
<item
path=
"src/linux-i2c.cpp"
ex=
"false"
tool=
"1"
flavor2=
"0"
>
</item>
<item
path=
"tests/linuxi2ctest.cpp"
ex=
"false"
tool=
"1"
flavor2=
"0"
>
</item>
</conf>
</confs>
</configurationDescriptor>
tests/linuxi2ctest.cpp
0 → 100644
View file @
421a4a62
/*
* File: linuxi2ctest.cpp
* Author: ericfoss
*/
#include <stdlib.h>
#include <iostream>
#include "linux-i2c.h"
/*
* Simple C++ Test Suite
*/
const
char
GOOD_ADDR
=
0x4c
;
void
bad_path_test
()
{
bool
threw
=
false
;
try
{
LinuxI2c
i2c
(
"/fake/path"
,
GOOD_ADDR
);
}
catch
(...)
{
threw
=
true
;
}
if
(
!
threw
)
{
std
::
cout
<<
"%TEST_FAILED% time=0 testname=bad_path_test (linuxi2ctest) message=Bad constructor didn't throw"
<<
std
::
endl
;
}
}
void
bad_address_test
()
{
bool
threw
=
false
;
try
{
LinuxI2c
i2c
(
"/dev/i2c2"
,
0x00
);
}
catch
(...)
{
threw
=
true
;
}
if
(
!
threw
)
{
std
::
cout
<<
"%TEST_FAILED% time=0 testname=bad_address_test (linuxi2ctest) message=Bad constructor didn't throw"
<<
std
::
endl
;
}
}
void
good_construtor_test
()
{
bool
threw
=
true
;
try
{
LinuxI2c
i2c
(
"/dev/i2c2"
,
GOOD_ADDR
);
threw
=
false
;
}
catch
(...)
{}
if
(
threw
)
{
std
::
cout
<<
"%TEST_FAILED% time=0 testname=good_construtor_test (linuxi2ctest) message=Good constructor threw"
<<
std
::
endl
;
}
}
int
main
(
int
argc
,
char
**
argv
)
{
std
::
cout
<<
"%SUITE_STARTING% linuxi2ctest"
<<
std
::
endl
;
std
::
cout
<<
"%SUITE_STARTED%"
<<
std
::
endl
;
std
::
cout
<<
"%TEST_STARTED% bad_path_test (linuxi2ctest)"
<<
std
::
endl
;
bad_path_test
();
std
::
cout
<<
"%TEST_FINISHED% time=0 bad_path_test (linuxi2ctest)"
<<
std
::
endl
;
std
::
cout
<<
"%TEST_STARTED% bad_address_test (linuxi2ctest)"
<<
std
::
endl
;
bad_address_test
();
std
::
cout
<<
"%TEST_FINISHED% time=0 bad_address_test (linuxi2ctest)"
<<
std
::
endl
;
std
::
cout
<<
"%TEST_STARTED% good_construtor_test (linuxi2ctest)"
<<
std
::
endl
;
good_construtor_test
();
std
::
cout
<<
"%TEST_FINISHED% time=0 good_construtor_test (linuxi2ctest)"
<<
std
::
endl
;
std
::
cout
<<
"%SUITE_FINISHED% time=0"
<<
std
::
endl
;
return
(
EXIT_SUCCESS
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment