Skip to content

Commit

Permalink
[NFC] Apply clang-format suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
eguiraud committed Oct 1, 2023
1 parent 1dae46e commit cca7b8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
*/
#include "absl/container/flat_hash_map.h"

#include <memory>
#include <string>
#include <string_view>

#include "absl/container/flat_hash_map.h"

/* A note on the use of shared_ptr<const T>
They are not as bad as they might seem at first sight:
Expand Down
18 changes: 6 additions & 12 deletions tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@ TEST(Graph, SumEval) {

const Graph g3 = x + c; // Var + Const
const Graph g4 = c + x; // Const + Var
for (const auto &g: {g3, g4})
EXPECT_DOUBLE_EQ(g.eval(inputs), 5.);
for (const auto &g : {g3, g4}) EXPECT_DOUBLE_EQ(g.eval(inputs), 5.);

const Graph g5 = x + g1; // Var + Graph
const Graph g6 = g1 + x; // Graph + Var
for (const auto &g: {g5, g6})
EXPECT_DOUBLE_EQ(g.eval(inputs), 9.);
for (const auto &g : {g5, g6}) EXPECT_DOUBLE_EQ(g.eval(inputs), 9.);

const Graph g7 = c + g1; // Const + Graph
const Graph g8 = g1 + c; // Graph + Const
for (const auto &g: {g7, g8})
EXPECT_DOUBLE_EQ(g.eval(inputs), 8.);
for (const auto &g : {g7, g8}) EXPECT_DOUBLE_EQ(g.eval(inputs), 8.);

// Graph and Graph
const auto g9 = g1 + g1; // Graph + Graph
Expand All @@ -48,18 +45,15 @@ TEST(Graph, MulEval) {

const Graph g3 = x * c; // Var * Const
const Graph g4 = c * x; // Const * Var
for (const auto &g: {g3, g4})
EXPECT_DOUBLE_EQ(g.eval(inputs), 6.);
for (const auto &g : {g3, g4}) EXPECT_DOUBLE_EQ(g.eval(inputs), 6.);

const Graph g5 = x * g1; // Var * Graph
const Graph g6 = g1 * x; // Graph * Var
for (const auto &g: {g5, g6})
EXPECT_DOUBLE_EQ(g.eval(inputs), 27.);
for (const auto &g : {g5, g6}) EXPECT_DOUBLE_EQ(g.eval(inputs), 27.);

const Graph g7 = c * g1; // Const * Graph
const Graph g8 = g1 * c; // Graph * Const
for (const auto &g: {g7, g8})
EXPECT_DOUBLE_EQ(g.eval(inputs), 18.);
for (const auto &g : {g7, g8}) EXPECT_DOUBLE_EQ(g.eval(inputs), 18.);

// Graph and Graph
const auto g9 = g1 * g1; // Graph * Graph
Expand Down

0 comments on commit cca7b8d

Please sign in to comment.