OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HeavyDBAsserts.java
Go to the documentation of this file.
1 /*
2  * Copyright 2015 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.mapd.tests;
17 
18 import ai.heavy.thrift.server.TDashboard;
19 
20 public class HeavyDBAsserts {
21  public static interface TestRun { void run() throws Exception; }
22 
23  public static void assertEqual(Object a, Object b) {
24  if (a.equals(b)) return;
25  throw new RuntimeException("assert failed:\nExpected: " + a + "\n got: " + b);
26  }
27 
28  public static void assertEqual(int a, int b) {
29  if (a == b) return;
30  throw new RuntimeException("assert failed:\nExpected: " + a + "\n got: " + b);
31  }
32 
33  public static void assertEqual(String name, TDashboard db) {
34  assertEqual(name, db.getDashboard_name());
35  assertEqual(name + "_hash", db.getImage_hash());
36  assertEqual(name + "_meta", db.getDashboard_metadata());
37  }
38 
39  public static void shouldThrowException(String msg, TestRun test) {
40  boolean failed;
41  try {
42  test.run();
43  failed = true;
44  } catch (Exception e) {
45  failed = false;
46  }
47 
48  if (failed) {
49  throw new RuntimeException(msg);
50  }
51  }
52 }
static void shouldThrowException(String msg, TestRun test)
static void assertEqual(String name, TDashboard db)
constexpr double a
Definition: Utm.h:32
static void assertEqual(Object a, Object b)
static void assertEqual(int a, int b)
string name
Definition: setup.in.py:72