Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
e4bc76f5
Commit
e4bc76f5
authored
12 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Patches
Plain Diff
Add a bit of unit test for inventory
parent
81c5e520
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test.cpp
+94
-0
94 additions, 0 deletions
src/test.cpp
with
94 additions
and
0 deletions
src/test.cpp
+
94
−
0
View file @
e4bc76f5
...
...
@@ -37,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include
"log.h"
#include
"utility_string.h"
#include
"voxelalgorithms.h"
#include
"inventory.h"
/*
Asserts that the exception occurs
...
...
@@ -650,6 +651,98 @@ struct TestVoxelAlgorithms
}
};
struct
TestInventory
{
void
Run
(
IItemDefManager
*
idef
)
{
std
::
string
serialized_inventory
=
"List 0 32
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Item default:cobble 61
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Item default:dirt 71
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Item default:dirt 99
\n
"
"Item default:cobble 38
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"EndInventoryList
\n
"
"EndInventory
\n
"
;
std
::
string
serialized_inventory_2
=
"List main 32
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Item default:cobble 61
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Item default:dirt 71
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Item default:dirt 99
\n
"
"Item default:cobble 38
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"Empty
\n
"
"EndInventoryList
\n
"
"EndInventory
\n
"
;
Inventory
inv
(
idef
);
std
::
istringstream
is
(
serialized_inventory
,
std
::
ios
::
binary
);
inv
.
deSerialize
(
is
);
assert
(
inv
.
getList
(
"0"
));
assert
(
!
inv
.
getList
(
"main"
));
inv
.
getList
(
"0"
)
->
setName
(
"main"
);
assert
(
!
inv
.
getList
(
"0"
));
assert
(
inv
.
getList
(
"main"
));
std
::
ostringstream
inv_os
(
std
::
ios
::
binary
);
inv
.
serialize
(
inv_os
);
assert
(
inv_os
.
str
()
==
serialized_inventory_2
);
}
};
/*
NOTE: These tests became non-working then NodeContainer was removed.
These should be redone, utilizing some kind of a virtual
...
...
@@ -1447,6 +1540,7 @@ void run_tests()
TESTPARAMS
(
TestMapNode
,
ndef
);
TESTPARAMS
(
TestVoxelManipulator
,
ndef
);
TESTPARAMS
(
TestVoxelAlgorithms
,
ndef
);
TESTPARAMS
(
TestInventory
,
idef
);
//TEST(TestMapBlock);
//TEST(TestMapSector);
if
(
INTERNET_SIMULATOR
==
false
){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment