xref: /aosp_15_r20/external/cronet/base/containers/fixed_flat_set_nocompile.nc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1// Copyright 2024 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// This is a "No Compile Test" suite.
6// http://dev.chromium.org/developers/testing/no-compile-tests
7
8#include "base/containers/fixed_flat_set.h"
9
10// Constructing a fixed flat set with duplicate keys should not compile.
11auto kDuplicates = base::MakeFixedFlatSet<int>({1, 1, 2, 3});  // expected-error-re {{call to consteval function 'base::MakeFixedFlatSet<{{.+}}>' is not a constant expression}}
12
13// Constructing a fixed flat set with the sorted_unique tag but unsorted keys
14// should not compile.
15auto kNotActuallySorted = base::MakeFixedFlatSet<int>(base::sorted_unique, {3, 2, 1});  // expected-error-re {{call to consteval function 'base::MakeFixedFlatSet<{{.+}}>' is not a constant expression}}
16
17// Constructing a fixed flat set with the sorted_unique tag but duplicate keys
18// should not compile.
19auto kSortedButDuplicates = base::MakeFixedFlatSet<int>(base::sorted_unique, {1, 1, 2});  // expected-error-re {{call to consteval function 'base::MakeFixedFlatSet<{{.+}}>' is not a constant expression}}
20