1 //===- DialectTest.cpp - Dialect unit tests -------------------------------===//
2 //
3 // Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "mlir/IR/Dialect.h"
10 #include "gtest/gtest.h"
11 
12 using namespace mlir;
13 using namespace mlir::detail;
14 
15 namespace {
16 struct TestDialect : public Dialect {
TestDialect__anon3cac2e2e0111::TestDialect17   TestDialect(MLIRContext *context) : Dialect(/*name=*/"test", context) {}
18 };
19 
TEST(DialectDeathTest,MultipleDialectsWithSameNamespace)20 TEST(DialectDeathTest, MultipleDialectsWithSameNamespace) {
21   MLIRContext context;
22 
23   // Registering a dialect with the same namespace twice should result in a
24   // failure.
25   new TestDialect(&context);
26   ASSERT_DEATH(new TestDialect(&context), "");
27 }
28 
29 } // end namespace
30