Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
azrogers committed Jan 15, 2025
1 parent 4e31892 commit 5c3a0ed
Show file tree
Hide file tree
Showing 8 changed files with 567 additions and 566 deletions.
28 changes: 13 additions & 15 deletions Cesium3DTilesReader/test/TestTilesetReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@

using namespace doctest;

bool compareVectors(const std::vector<double>& a, const std::vector<double>& b) {
if(a.size() != b.size()) {
bool compareVectors(
const std::vector<double>& a,
const std::vector<double>& b) {
if (a.size() != b.size()) {
return false;
}

for(size_t i = 0; i < a.size(); i++) {
if(a[i] != doctest::Approx(b[i])) {
for (size_t i = 0; i < a.size(); i++) {
if (a[i] != doctest::Approx(b[i])) {
return false;
}
}

return true;
}

Expand Down Expand Up @@ -91,24 +93,20 @@ TEST_CASE("Reads tileset JSON") {
0,
158.4};

REQUIRE(
compareVectors(tileset.root.boundingVolume.region,
expectedRegion));
REQUIRE(compareVectors(tileset.root.boundingVolume.region, expectedRegion));

REQUIRE(
compareVectors(tileset.root.content->boundingVolume->region,
REQUIRE(compareVectors(
tileset.root.content->boundingVolume->region,
expectedContentRegion));

REQUIRE(tileset.root.children.size() == 4);

const Cesium3DTiles::Tile& child = tileset.root.children[0];

REQUIRE(
compareVectors(child.boundingVolume.region,
expectedChildRegion));
REQUIRE(compareVectors(child.boundingVolume.region, expectedChildRegion));

REQUIRE(
compareVectors(child.content->boundingVolume->region,
REQUIRE(compareVectors(
child.content->boundingVolume->region,
expectedChildContentRegion));

CHECK(child.content->uri == "1/0/0.b3dm");
Expand Down
207 changes: 104 additions & 103 deletions CesiumAsync/test/TestCacheAssetAccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,181 +142,182 @@ TEST_CASE("Test the condition of caching the request") {
SUBCASE("GET request, has max-age, cacheable status code") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
HttpHeaders headers = {
{"Content-Type", "app/json"},
{"Cache-Control", "must-revalidate, max-age=100"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
for (auto& statusCode : statusCodes) {
HttpHeaders headers = {
{"Content-Type", "app/json"},
{"Cache-Control", "must-revalidate, max-age=100"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, has Expires header, cacheable status code") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

HttpHeaders headers = {
{"Content-Type", "app/json"},
{"Expires", "Wed, 21 Oct 5020 07:28:00 GMT"}};
HttpHeaders headers = {
{"Content-Type", "app/json"},
{"Expires", "Wed, 21 Oct 5020 07:28:00 GMT"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, max-age 0, old Expires header") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

// Similar to Google Photorealistic 3D Tiles, root request
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control", "private, max-age=0, must-revalidate"},
{"ETag", "deadbeef"},
{"Expires", "Mon, 01 Jan 1990 00:00:00 GMT"}};
// Similar to Google Photorealistic 3D Tiles, root request
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control", "private, max-age=0, must-revalidate"},
{"ETag", "deadbeef"},
{"Expires", "Mon, 01 Jan 1990 00:00:00 GMT"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, max-age 0, stale-while-revalidate") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

// Similar to Google Photorealistic 3D Tiles, tile request
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control", "private, max-age=0, stale-while-revalidate=86400"},
{"ETag", "deadbeef"}};
// Similar to Google Photorealistic 3D Tiles, tile request
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control",
"private, max-age=0, stale-while-revalidate=86400"},
{"ETag", "deadbeef"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, no-cache with Etag") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control", "no-cache"},
{"ETag", "deadbeef"}};
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control", "no-cache"},
{"ETag", "deadbeef"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, no-cache with Last-Modified") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control", "no-cache"},
{"Last-Modified", "Mon, 01 Jan 1990 00:00:00 GMT"}};
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control", "no-cache"},
{"Last-Modified", "Mon, 01 Jan 1990 00:00:00 GMT"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, just Last-Modified") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Last-Modified", "Mon, 01 Jan 1990 00:00:00 GMT"}};
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Last-Modified", "Mon, 01 Jan 1990 00:00:00 GMT"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, just Etag") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

HttpHeaders headers = {
{"Content-Type", "application/json"},
{"ETag", "deadbeef"}};
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"ETag", "deadbeef"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE(
"GET Request, Expires header is less than current, but has an ETag") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

HttpHeaders headers = {
{"Content-Type", "application/json"},
{"ETag", "deadbeef"},
{"Expires", "Wed, 21 Oct 2010 07:28:00 GMT"}};
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"ETag", "deadbeef"},
{"Expires", "Wed, 21 Oct 2010 07:28:00 GMT"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, Expires header is less than current, but has a "
"Last-Modified") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Last-Modified", "Mon, 01 Jan 1990 00:00:00 GMT"},
{"Expires", "Wed, 21 Oct 2010 07:28:00 GMT"}};
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Last-Modified", "Mon, 01 Jan 1990 00:00:00 GMT"},
{"Expires", "Wed, 21 Oct 2010 07:28:00 GMT"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, max-age is zero, but has an ETag") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

HttpHeaders headers = {
{"Content-Type", "application/json"},
{"ETag", "deadbeef"},
{"Cache-Control", "max-age=0"}};
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"ETag", "deadbeef"},
{"Cache-Control", "max-age=0"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}

SUBCASE("GET Request, max-age is zero, but has a Last-Modified") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
for (auto& statusCode : statusCodes) {

HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Last-Modified", "Mon, 01 Jan 1990 00:00:00 GMT"},
{"Cache-Control", "max-age=0"}};
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Last-Modified", "Mon, 01 Jan 1990 00:00:00 GMT"},
{"Cache-Control", "max-age=0"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == true);
}
}
}

Expand Down Expand Up @@ -546,14 +547,14 @@ TEST_CASE("Test the condition of caching the request") {
SUBCASE("No store if max-age=0 and response has no ETag or Last-Modified") {
std::vector<int> statusCodes{200, 202, 203, 204, 205, 304};

for(auto& statusCode : statusCodes) {
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control", "max-age=0"}};
for (auto& statusCode : statusCodes) {
HttpHeaders headers = {
{"Content-Type", "application/json"},
{"Cache-Control", "max-age=0"}};

bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == false);
}
bool responseCached = runResponseCacheTest(statusCode, "GET", headers);
CHECK(responseCached == false);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions CesiumGeometry/test/TestBoundingSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TEST_CASE("BoundingSphere::intersectPlane") {
CullingResult expectedResult;
};

std::vector<TestCase> testCases {
std::vector<TestCase> testCases{
// sphere on the positive side of a plane
TestCase{
BoundingSphere(glm::dvec3(0.0), 0.5),
Expand All @@ -40,7 +40,7 @@ TEST_CASE("BoundingSphere::intersectPlane") {
Plane(glm::dvec3(1.0, 0.0, 0.0), -1.0),
CullingResult::Intersecting}};

for(auto& testCase : testCases) {
for (auto& testCase : testCases) {
CHECK(
testCase.sphere.intersectPlane(testCase.plane) ==
testCase.expectedResult);
Expand Down
Loading

0 comments on commit 5c3a0ed

Please sign in to comment.