Skip to content

Commit

Permalink
Merge pull request #168 from ngageoint/sync_externals
Browse files Browse the repository at this point in the history
Sync externals
  • Loading branch information
asylvest authored Mar 16, 2017
2 parents 5ef98d6 + eb66b59 commit 43577b6
Show file tree
Hide file tree
Showing 5 changed files with 2,745 additions and 108 deletions.
5 changes: 3 additions & 2 deletions externals/coda-oss/modules/c++/include/TestCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# include <import/sys.h>
# include <import/str.h>

# define IS_NAN(X) X != X
# define TEST_CHECK(X) try{ X(std::string(#X)); std::cerr << #X << ": PASSED" << std::endl; } catch(except::Throwable& ex) { die_printf("%s: FAILED: Exception thrown: %s\n", std::string(#X).c_str(), ex.toString().c_str()); }
# define TEST_ASSERT(X) if (!(X)) { die_printf("%s (%s,%s,%d): FAILED: Value should not be NULL\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
# define TEST_ASSERT_NULL(X) if ((X) != NULL) { die_printf("%s (%s,%s,%d): FAILED: Value should be NULL\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
Expand All @@ -39,8 +40,8 @@
# define TEST_ASSERT_EQ_MSG(msg, X1, X2) if ((X1) != (X2)) die_printf("%s (%s,%d): FAILED (%s): Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, __LINE__, (msg).c_str(), str::toString((X1)).c_str(), str::toString((X2)).c_str());
# define TEST_ASSERT_NOT_EQ(X1, X2) if ((X1) == (X2)) { die_printf("%s (%s,%s,%d): FAILED: Recv'd %s should not equal %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(X1).c_str(), str::toString(X2).c_str()); }
# define TEST_ASSERT_NOT_EQ_MSG(msg, X1, X2) if ((X1) == (X2)) die_printf("%s (%s,%d): FAILED (%s): Recv'd %s should not equal %s\n", testName.c_str(), __FILE__, __LINE__, (msg).c_str(), str::toString((X1)).c_str(), str::toString((X2)).c_str());
# define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) if (std::abs((X1) - (X2)) > EPS) die_printf("%s (%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, __LINE__, str::toString((X1)).c_str(), str::toString((X2)).c_str());
# define TEST_ASSERT_ALMOST_EQ(X1, X2) if (std::abs((X1) - (X2)) > std::numeric_limits<float>::epsilon()) { die_printf("%s (%s,%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(X1).c_str(), str::toString(X2).c_str()); }
# define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) if (std::abs((X1) - (X2)) > EPS || IS_NAN(std::abs((X1) - (X2)))) die_printf("%s (%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, __LINE__, str::toString((X1)).c_str(), str::toString((X2)).c_str());
# define TEST_ASSERT_ALMOST_EQ(X1, X2) if (std::abs((X1) - (X2)) > std::numeric_limits<float>::epsilon() || IS_NAN(std::abs((X1) - (X2)))) { die_printf("%s (%s,%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(X1).c_str(), str::toString(X2).c_str()); }
# define TEST_ASSERT_GREATER_EQ(X1, X2) if ((X1) < X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be greater than or equal\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
# define TEST_ASSERT_GREATER(X1, X2) if ((X1) <= X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be greater than\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
# define TEST_ASSERT_LESSER_EQ(X1, X2) if ((X1) > X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be less than or equal\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
Expand Down
68 changes: 68 additions & 0 deletions externals/coda-oss/modules/c++/sys/unittests/test_NaN_testing.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* =========================================================================
* This file is part of sys-c++
* =========================================================================
*
* (C) Copyright 2004 - 2017, MDA Information Systems LLC
*
* sys-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/

#include <limits>
#include "TestCase.h"

namespace
{
TEST_CASE(testNaNsAreNotEqual)
{
// This test exists mainly to document behavior
// It's not awesome that things work this way, but presumably
// the caller is testing against a known value, so if this comes up
// NaN oddness is already expected.
TEST_ASSERT_NOT_EQ(std::numeric_limits<float>::quiet_NaN(),
std::numeric_limits<float>::quiet_NaN());

TEST_ASSERT_NOT_EQ(std::numeric_limits<float>::quiet_NaN(), 3.4);

}

TEST_CASE(testNaNIsNotAlmostEqualToNumber)
{
// Uncomment the test to see it work.
// These test macros are supposed to fail here.
// But I don't have a way to intercept the failure.
//
/*
TEST_ASSERT_ALMOST_EQ(std::numeric_limits<float>::quiet_NaN(), 5);
TEST_ASSERT_ALMOST_EQ_EPS(std::numeric_limits<float>::quiet_NaN(),
5, 3);
*/
}

TEST_CASE(testIsNaN)
{
TEST_ASSERT_TRUE(IS_NAN(std::numeric_limits<float>::quiet_NaN()));
TEST_ASSERT_FALSE(IS_NAN(5));
TEST_ASSERT_FALSE(IS_NAN(std::string("test string")));
}
}

int main(int /*argc*/, char** /*argv*/)
{
TEST_CHECK(testNaNsAreNotEqual);
TEST_CHECK(testNaNIsNotAlmostEqualToNumber);
TEST_CHECK(testIsNaN);
}

216 changes: 216 additions & 0 deletions externals/coda-oss/modules/python/types/source/generated/coda_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,222 @@ def __setstate__(self, state):
VectorSizeT_swigregister = _coda_types.VectorSizeT_swigregister
VectorSizeT_swigregister(VectorSizeT)

class VectorString(_object):
"""Proxy of C++ std::vector<(std::string)> class."""

__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, VectorString, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, VectorString, name)
__repr__ = _swig_repr

def iterator(self):
"""iterator(VectorString self) -> SwigPyIterator"""
return _coda_types.VectorString_iterator(self)

def __iter__(self):
return self.iterator()

def __nonzero__(self):
"""__nonzero__(VectorString self) -> bool"""
return _coda_types.VectorString___nonzero__(self)


def __bool__(self):
"""__bool__(VectorString self) -> bool"""
return _coda_types.VectorString___bool__(self)


def __len__(self):
"""__len__(VectorString self) -> std::vector< std::string >::size_type"""
return _coda_types.VectorString___len__(self)


def __getslice__(self, i, j):
"""__getslice__(VectorString self, std::vector< std::string >::difference_type i, std::vector< std::string >::difference_type j) -> VectorString"""
return _coda_types.VectorString___getslice__(self, i, j)


def __setslice__(self, *args):
"""
__setslice__(VectorString self, std::vector< std::string >::difference_type i, std::vector< std::string >::difference_type j)
__setslice__(VectorString self, std::vector< std::string >::difference_type i, std::vector< std::string >::difference_type j, VectorString v)
"""
return _coda_types.VectorString___setslice__(self, *args)


def __delslice__(self, i, j):
"""__delslice__(VectorString self, std::vector< std::string >::difference_type i, std::vector< std::string >::difference_type j)"""
return _coda_types.VectorString___delslice__(self, i, j)


def __delitem__(self, *args):
"""
__delitem__(VectorString self, std::vector< std::string >::difference_type i)
__delitem__(VectorString self, PySliceObject * slice)
"""
return _coda_types.VectorString___delitem__(self, *args)


def __getitem__(self, *args):
"""
__getitem__(VectorString self, PySliceObject * slice) -> VectorString
__getitem__(VectorString self, std::vector< std::string >::difference_type i) -> std::vector< std::string >::value_type const &
"""
return _coda_types.VectorString___getitem__(self, *args)


def __setitem__(self, *args):
"""
__setitem__(VectorString self, PySliceObject * slice, VectorString v)
__setitem__(VectorString self, PySliceObject * slice)
__setitem__(VectorString self, std::vector< std::string >::difference_type i, std::vector< std::string >::value_type const & x)
"""
return _coda_types.VectorString___setitem__(self, *args)


def pop(self):
"""pop(VectorString self) -> std::vector< std::string >::value_type"""
return _coda_types.VectorString_pop(self)


def append(self, x):
"""append(VectorString self, std::vector< std::string >::value_type const & x)"""
return _coda_types.VectorString_append(self, x)


def empty(self):
"""empty(VectorString self) -> bool"""
return _coda_types.VectorString_empty(self)


def size(self):
"""size(VectorString self) -> std::vector< std::string >::size_type"""
return _coda_types.VectorString_size(self)


def swap(self, v):
"""swap(VectorString self, VectorString v)"""
return _coda_types.VectorString_swap(self, v)


def begin(self):
"""begin(VectorString self) -> std::vector< std::string >::iterator"""
return _coda_types.VectorString_begin(self)


def end(self):
"""end(VectorString self) -> std::vector< std::string >::iterator"""
return _coda_types.VectorString_end(self)


def rbegin(self):
"""rbegin(VectorString self) -> std::vector< std::string >::reverse_iterator"""
return _coda_types.VectorString_rbegin(self)


def rend(self):
"""rend(VectorString self) -> std::vector< std::string >::reverse_iterator"""
return _coda_types.VectorString_rend(self)


def clear(self):
"""clear(VectorString self)"""
return _coda_types.VectorString_clear(self)


def get_allocator(self):
"""get_allocator(VectorString self) -> std::vector< std::string >::allocator_type"""
return _coda_types.VectorString_get_allocator(self)


def pop_back(self):
"""pop_back(VectorString self)"""
return _coda_types.VectorString_pop_back(self)


def erase(self, *args):
"""
erase(VectorString self, std::vector< std::string >::iterator pos) -> std::vector< std::string >::iterator
erase(VectorString self, std::vector< std::string >::iterator first, std::vector< std::string >::iterator last) -> std::vector< std::string >::iterator
"""
return _coda_types.VectorString_erase(self, *args)


def __init__(self, *args):
"""
__init__(std::vector<(std::string)> self) -> VectorString
__init__(std::vector<(std::string)> self, VectorString arg2) -> VectorString
__init__(std::vector<(std::string)> self, std::vector< std::string >::size_type size) -> VectorString
__init__(std::vector<(std::string)> self, std::vector< std::string >::size_type size, std::vector< std::string >::value_type const & value) -> VectorString
"""
this = _coda_types.new_VectorString(*args)
try:
self.this.append(this)
except __builtin__.Exception:
self.this = this

def push_back(self, x):
"""push_back(VectorString self, std::vector< std::string >::value_type const & x)"""
return _coda_types.VectorString_push_back(self, x)


def front(self):
"""front(VectorString self) -> std::vector< std::string >::value_type const &"""
return _coda_types.VectorString_front(self)


def back(self):
"""back(VectorString self) -> std::vector< std::string >::value_type const &"""
return _coda_types.VectorString_back(self)


def assign(self, n, x):
"""assign(VectorString self, std::vector< std::string >::size_type n, std::vector< std::string >::value_type const & x)"""
return _coda_types.VectorString_assign(self, n, x)


def resize(self, *args):
"""
resize(VectorString self, std::vector< std::string >::size_type new_size)
resize(VectorString self, std::vector< std::string >::size_type new_size, std::vector< std::string >::value_type const & x)
"""
return _coda_types.VectorString_resize(self, *args)


def insert(self, *args):
"""
insert(VectorString self, std::vector< std::string >::iterator pos, std::vector< std::string >::value_type const & x) -> std::vector< std::string >::iterator
insert(VectorString self, std::vector< std::string >::iterator pos, std::vector< std::string >::size_type n, std::vector< std::string >::value_type const & x)
"""
return _coda_types.VectorString_insert(self, *args)


def reserve(self, n):
"""reserve(VectorString self, std::vector< std::string >::size_type n)"""
return _coda_types.VectorString_reserve(self, n)


def capacity(self):
"""capacity(VectorString self) -> std::vector< std::string >::size_type"""
return _coda_types.VectorString_capacity(self)


def __getstate__(self):
# Return a nonempty (thus non-false) tuple with dummy value in first position
return (-1, tuple(pickle.dumps(elem) for elem in self))

def __setstate__(self, state):
self.__init__()
# State will have a dummy entry in the first position
for elem in state[1]:
self.push_back(pickle.loads(elem))

__swig_destroy__ = _coda_types.delete_VectorString
__del__ = lambda self: None
VectorString_swigregister = _coda_types.VectorString_swigregister
VectorString_swigregister(VectorString)

# This file is compatible with both classic and new-style classes.


Loading

0 comments on commit 43577b6

Please sign in to comment.