Peter Johnson
53d0789660
Storage: Escape equal sign in strings. ( #119 )
...
This helps interoperability with standard config parser libraries
(such as Python's RawConfigParser).
2016-09-29 20:16:32 -07:00
Peter Johnson
f6b700ea97
Move common utility classes to wpiutil library. ( #79 )
...
This is a breaking change to dependencies that use the static ntcore
library. Unless the wpiutil library is also linked, linker errors will
result. This does not affect the shared ntcore library.
2016-09-25 17:23:39 -07:00
Peter Johnson
a73166a665
Make many more utility classes/headers public. ( #76 )
...
Moving these headers from src to include enables other libraries to use the
functionality provided.
* tcpsockets
* atomic_static
* raw_istream
* timestamp
* SafeThread
* Base64
* LEB128
* ConcurrentQueue
The classes have been moved into the wpi namespace as they're generic.
2016-07-27 00:39:38 -07:00
Thad House
58092c5190
Adds SetDefault methods to NetworkTables ( #54 )
...
There was no way to atomically check for a key in the table,
and then setting if it if non existant. Back before persistent
this was not a problem, however now it is, as its possible for
values to be added before team's robot programs start. This makes
the old method of calling Put*** methods in RobotInit invalid.
This adds SetDefault methods, which do this atomically.
2016-07-13 00:31:03 -07:00
Peter Johnson
4b516de183
Don't delete persistent entries in DeleteAllEntries. ( #71 )
...
This is a behavior change but without it DeleteAllEntries is dangerous and
not very useful, so I consider the current behavior to be a bug.
2016-06-17 22:33:02 -07:00
Peter Johnson
c90a8c586f
getTable(): Don't prepend slash if key already starts with it.
...
This makes getTable("/foo") and getTable("foo") equivalent.
2016-01-14 21:38:04 -08:00
Peter Johnson
7528b6b8bf
Fix NetworkTable::ContainsKey.
...
Previously this would always return false due to how explicit bool is
evaluated in a return context.
Also add a test for this function.
Reported by: jcreigh
2015-12-19 08:47:52 -08:00
Peter Johnson
57b00d3b38
Fix StorageTest unit test on MSVC 2015.
...
Per https://msdn.microsoft.com/en-us/library/bb531344.aspx , "Exponent
formatting", MSVC 2015 fixed the %g format to match the C standard's
requirement of printing a 2-digit exponent if only 2 digits are
required.
2015-10-05 20:22:36 -07:00
Peter Johnson
123ba9c670
Use SmallVector instead of malloc buffers for WireEncoder.
2015-09-06 11:00:44 -07:00
Peter Johnson
2dd9eafa4f
Enable "make test" on cmake.
2015-09-03 21:31:31 -07:00
Fredric Silberberg
b1783cc1db
Integrate googletest and googlemock.
2015-09-03 21:31:26 -07:00
Peter Johnson
0f4eecebe6
Fix StorageTest on MSVC.
...
MSVC outputs %g with a 3-digit instead of a 2-digit exponent.
2015-08-24 21:30:07 -07:00
Peter Johnson
c27a1cec48
Unbreak StorageTest.
2015-08-22 23:26:22 -07:00
Peter Johnson
293d005432
Turn on logging in unit tests.
2015-08-13 22:14:17 -07:00
Peter Johnson
b3eed38187
Get build working on Windows (MSVC 2013).
...
Windows needs static libraries to build the tests as gtest/gmock are built statically.
2015-08-04 01:29:06 -07:00
Peter Johnson
4146db6fc8
Visual Studio 2013 compilation fixes.
...
- Missing header file callouts in some cases (library deltas)
- Lack of support for auto parameters in lambdas
- Defining of ERROR by windows.h
- Dispatcher::Connection needs a move constructor (default not generated)
- Need explicit enable_if on std::string move template in Value to avoid trying to move const char[] (string literal)
- Compile flags
2015-08-03 01:27:02 -07:00
Peter Johnson
4670ef6ec5
Refactor StorageTest base class.
2015-08-01 16:33:52 -07:00
Peter Johnson
67de7af7b2
Storage: Use unique_ptr instead of shared_ptr for Entry.
2015-08-01 11:47:35 -07:00
Peter Johnson
3b207ad2c3
StorageTest: Fix string comparison for Warn().
...
Previously this was comparing pointers rather than the string contents.
2015-08-01 11:45:41 -07:00
Peter Johnson
cde7782c21
Make StorageEntry a struct and move into Storage class.
2015-07-31 13:48:33 -07:00
Peter Johnson
138ebf5b4d
Storage: generate messages rather than intermediate updates.
2015-07-31 13:21:19 -07:00
Peter Johnson
a0d30ffef1
Storage: Use StringMap instead of ConcurrentQueue for updates.
...
Updates are merged or themselves updated as user code changes. This avoids
the need for the dispatcher to do this and also avoids the need for disabling
updates when the dispatcher isn't running, because there's no risk of memory
usage piling up.
2015-07-26 20:41:48 -07:00
Peter Johnson
fb1b82e239
StorageEntry: Also store copy of name here.
...
This wastes a bit of space but is necessary for assign message generation.
2015-07-26 10:28:20 -07:00
Peter Johnson
18659257d3
Storage: Make setters globally atomic.
...
Previously, setters were locally but not globally atomic because they
used GetEntry() (globally atomic) in conjunction with locally atomic
gets/sets to the StorageEntry. To support synchronizing network handshakes
they need to be globally atomic.
GetEntry() has been removed due to this issue, so a helper was added to
StorageTest instead.
2015-07-26 09:27:23 -07:00
Peter Johnson
507b083e77
WireEncoderTest.cpp: Don't test compiler truncation.
2015-07-23 22:06:57 -07:00
Peter Johnson
13bc05d9ec
leb128Test: Fix incorrectly sized constants.
2015-07-23 22:04:51 -07:00
Peter Johnson
9c204533e8
Value: Disambiguate std::string&& and StringRef.
...
Making the former a template causes the compiler to prefer the latter
when given a bare C string.
2015-07-22 22:08:13 -07:00
Peter Johnson
5df62ac172
Storage: Disable use of update queue by default.
...
This ensures we don't "leak" memory for local use when the dispatch thread
is not running.
2015-07-20 22:24:47 -07:00
Peter Johnson
29691e0ac5
StorageTest: Add LoadPersistent and SavePersistent coverage.
2015-07-19 22:45:20 -07:00
Peter Johnson
b0802f3e26
StorageTest: Add fixture classes, add GetEntryInfo test.
2015-07-19 19:43:27 -07:00
Peter Johnson
67ae9e1ba7
Add initial set of unit tests for Storage.
2015-07-19 18:11:36 -07:00
Peter Johnson
cf18355fe2
Unit tests: Prefer constructor to SetUp() in fixtures.
2015-07-19 16:30:04 -07:00
Peter Johnson
fcbd2751ba
Provide C++ API. Move all classes to "nt" namespace.
...
The C API is now just simple wrappers around the C++ API.
2015-07-17 07:21:07 -07:00
Peter Johnson
9906116d23
Don't base Value on NT_Value.
...
Also use std::string instead of NT_String.
Conversions to/from the internal structures will be done at the interface.
2015-07-16 01:38:27 -07:00
Peter Johnson
eecf0deeec
Add WireDecoder test and finish WireEncoder test.
...
Change-Id: I0d2b3421df55f8f986678b694bbd5481e8fc6e6b
2015-07-11 09:33:34 -07:00
Peter Johnson
1634773529
Finish WireEncoder tests and fix a bug.
...
Change-Id: Iddb6003cf2050aebbda4650a5596342288432fde
2015-07-11 09:33:34 -07:00
Peter Johnson
547e2ad72b
leb128 test: naming consistency
...
Change-Id: Ib37433110781d87f8736c82d4b8249d580b5a1dd
2015-07-11 09:33:34 -07:00
Peter Johnson
ca90648118
Add copyrights and header guards.
...
Change-Id: I1e4c22a1626095750b6ffa8e0edd5e078ef221ec
2015-07-11 09:33:34 -07:00
Peter Johnson
958fbaa819
ValueTest / StringValueTest: Make conversion function static.
...
Change-Id: Ia7411fd58cfd7ee9225a7c7f90534567e7ae02ba
2015-07-11 09:33:34 -07:00
Peter Johnson
fa19a54ab7
Separate ValueTest and StringValueTest into headers.
...
Change-Id: If326e6943a11f271ef939dc815a45ba0b4ee271c
2015-07-11 09:33:34 -07:00
Peter Johnson
c9c1b7e5d8
Rename test files.
...
Change-Id: If7a2894f21b86bf9e4036e3069a2e5602ca932b0
2015-07-11 09:33:34 -07:00
Peter Johnson
4d5e5c82d4
Start WireEncoder testing.
...
Change-Id: I0e4161f5b3cab167d3c3d650588671be8a1b78b3
2015-07-11 09:33:34 -07:00
Peter Johnson
09d6619a58
Add LEB128 test.
...
Change-Id: Iaeb2d818226a281a905cb69ef12725e504c3a03d
2015-07-11 09:33:34 -07:00
Peter Johnson
ae42eee8e1
More Base64 fixes (correct decode return value).
...
Change-Id: Ic8f5eb7efd39e1d155a458aa41e430232bee7c7d
2015-07-11 09:33:34 -07:00
Peter Johnson
1225d3ef75
Slight whitespace fix.
...
Change-Id: I752a000775efefd45cf5c5be0a084e855f68e13f
2015-07-11 09:33:34 -07:00
Peter Johnson
407ded6b8c
Use ASSERT_EQ with correct order of arguments.
...
Change-Id: Ieed4703283ae222df3aee8adb07ca1e65e863c62
2015-07-11 09:33:34 -07:00
Peter Johnson
c7b5266f9a
Add Base64 tests and fix a couple of bugs found.
...
Change-Id: I9762fe018be78cf38aa506026e78139e2479cd98
2015-07-11 09:33:33 -07:00
Peter Johnson
5a0fccc9cf
Add unit tests for StringValue and Value.
...
Add unit test framework to CMakeLists.txt.
Fix a couple of bugs found by unit tests.
Change-Id: I2092a7f0570fae0f19f9e083c4837ccefcc4ca1a
2015-07-11 09:33:33 -07:00