Skip to content

Commit

Permalink
windows fixes & ci (#24)
Browse files Browse the repository at this point in the history
* add windows ci config

* add test debuggin

* silence warning in test

* don't read from empty stream
  • Loading branch information
nmwsharp committed Jul 4, 2020
1 parent ce65fee commit 661b6f5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
25 changes: 23 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,31 @@ compiler:
- gcc
- clang

jobs:
# do this here rather than in matrix since we don't need multiple compilers
include:
- os: windows

before_script:
- cd test
- mkdir build
- cd build
- cmake ..
- cmake -DCMAKE_BUILD_TYPE=Debug ..

script: make && ./bin/ply-test
script:
- |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
make
./bin/ply-test
fi
- |
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
make
./bin/ply-test
fi
- |
if [ "$TRAVIS_OS_NAME" = "windows" ]; then
cmake --build "."
ls
./bin/Debug/ply-test.exe
fi
12 changes: 8 additions & 4 deletions happly.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,10 @@ class TypedListProperty : public Property {
size_t currSize = flattenedData.size();
size_t afterSize = currSize + count;
flattenedData.resize(afterSize);
stream.read((char*)&flattenedData[currSize], count * sizeof(T));
flattenedIndexStart.emplace_back(afterSize);
if (count > 0) {
stream.read((char*)&flattenedData[currSize], count * sizeof(T));
}
flattenedIndexStart.emplace_back(afterSize);
}

/**
Expand All @@ -523,8 +525,10 @@ class TypedListProperty : public Property {
size_t currSize = flattenedData.size();
size_t afterSize = currSize + count;
flattenedData.resize(afterSize);
stream.read((char*)&flattenedData[currSize], count * sizeof(T));
flattenedIndexStart.emplace_back(afterSize);
if (count > 0) {
stream.read((char*)&flattenedData[currSize], count * sizeof(T));
}
flattenedIndexStart.emplace_back(afterSize);

// Swap endian order of list elements
for (size_t iFlat = currSize; iFlat < afterSize; iFlat++) {
Expand Down
10 changes: 9 additions & 1 deletion test/main_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,20 @@ TEST(TypedListReadWriteTest, ReadWriteCharBinary) {
std::vector<std::vector<char>> testData{
{3}, {3, 0, 11, -128, 127}, {}, {}, {3, 11},
};
std::cout << "size: " << testData.size() << std::endl;
for(auto& v : testData) {
std::cout << "sub size: " << v.size() << std::endl;
}
plyOut.getElement("test_elem").addListProperty<char>("test_data", testData);

// ASCII read/write
plyOut.write("temp.ply", happly::DataFormat::Binary);
happly::PLYData plyIn("temp.ply");
std::vector<std::vector<char>> testDataBinary = plyIn.getElement("test_elem").getListProperty<char>("test_data");
std::cout << "size: " << testDataBinary.size() << std::endl;
for(auto& v : testDataBinary) {
std::cout << "sub size: " << v.size() << std::endl;
}
EXPECT_EQ(testData, testDataBinary);
}
TEST(TypedListReadWriteTest, ReadWriteCharBinarySwap) {
Expand Down Expand Up @@ -1137,7 +1145,7 @@ TEST(TypePromotionTest, FaceIndThrow) {

happly::PLYData ply;
ply.addElement("face", 3);
std::vector<std::vector<uint64_t>> faceInds{{1, 3, 1L << 40}, {0, 2, 4, 5}, {1, 1, 1}};
std::vector<std::vector<uint64_t>> faceInds{{1, 3, 1LL << 40}, {0, 2, 4, 5}, {1, 1, 1}};
EXPECT_THROW(ply.getElement("face").addListProperty("vertex_indices", faceInds), std::runtime_error);
}

Expand Down

0 comments on commit 661b6f5

Please sign in to comment.