[go: nahoru, domu]

Skip to content

Commit

Permalink
Make VpiListenerTracer.h be self-contained.
Browse files Browse the repository at this point in the history
The header relied on forward declared classes, but since it actually
accesses members (VpiLineNo() etc.), it needs a full declaration of
these.
  • Loading branch information
hzeller committed Jun 15, 2022
1 parent 79ecd7a commit 28af447
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions templates/VpiListenerTracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include "VpiListener.h"

#include "uhdm/uhdm.h" // Needed to know how to access VPI line/column

#include <ostream>
#include <string>

Expand Down
21 changes: 18 additions & 3 deletions tests/vpi_listener_test.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
// -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-

#include "uhdm/VpiListener.h"

#include <iostream>
#include <memory>
#include <stack>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "uhdm/uhdm.h"

// uhdm
#include "uhdm/VpiListener.h"
#include "uhdm/VpiListenerTracer.h"

// We include this last to make sure that the headers above don't accidentally
// depend on any class defined here
#include "uhdm/uhdm.h"

using namespace UHDM;
using testing::ElementsAre;
using testing::HasSubstr;

class MyVpiListener : public VpiListener {
protected:
Expand Down Expand Up @@ -125,3 +130,13 @@ TEST(VpiListenerTest, ProgramModule) {
};
EXPECT_EQ(listener->collected(), expected);
}

TEST(UhdmListenerTracerTest, ProgramModule) {
Serializer serializer;
const std::vector<vpiHandle>& design = buildModuleProg(&serializer);

std::stringstream out;
std::unique_ptr<VpiListenerTracer> listener(new VpiListenerTracer(out));
listener->listenDesigns(design);
EXPECT_THAT(out.str(), HasSubstr("enterDesign: [0,0:0,0]"));
}

0 comments on commit 28af447

Please sign in to comment.