blob: c11719193addfdddc394f1edfa35c0c6aa3d26d6 [file] [log] [blame]
// Copyright 2021 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the aLicense is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <utility>
#include "starboard/configuration.h"
#include "starboard/types.h"
namespace starboard::foo::bar::baz {
constexpr int life() {
return 42;
}
} // namespace starboard::foo::bar::baz
namespace starboard {
namespace nplb {
namespace {
// Test Structured bindings support, P0217R3
#ifndef __cpp_structured_bindings
#error "Structured bindings support is required"
#endif
constexpr char test_structured_bindings() {
auto [a, b] = std::pair<int, char>(42, 'A');
return b;
}
static_assert(test_structured_bindings() == 'A',
"Structured bindings support is required");
// Test UTF-8 literal support, N4267
#ifndef __cpp_unicode_literals
#error "Unicode literal support is required"
#endif
static_assert('A' == u8'A', "Unicode literal support is required");
// Test constexpr lambda support, P0170R1
constexpr int add_one(int n) {
return [n] { return n + 1; }();
}
static_assert(add_one(1) == 2, "Constexpr lambdas support is required");
// Test Nested Namespaces support
static_assert(starboard::foo::bar::baz::life() == 42,
"Nested Namespaces support is required");
// Test fallthrough support
constexpr int test_fallthrough(int n) {
switch (n) {
case 1:
return 1;
break;
case 2:
[[fallthrough]]; // intentional fallthrough
case 3:
return 3;
break;
}
return 0;
}
static_assert(test_fallthrough(2) == 3,
"[fallthrough]] attribute support is required");
} // namespace
} // namespace nplb
} // namespace starboard