Skip to content

Commit

Permalink
refactoring the markov program
Browse files Browse the repository at this point in the history
  • Loading branch information
ebott committed Sep 18, 2013
1 parent d60f16f commit d349c1a
Show file tree
Hide file tree
Showing 10 changed files with 32,966 additions and 0 deletions.
4 changes: 4 additions & 0 deletions markov_refactor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.*.o
.*.d
.test-*.passed
main
Binary file added markov_refactor/.test-markov_reader
Binary file not shown.
61 changes: 61 additions & 0 deletions markov_refactor/.test.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @file
* @copyright Ken Smith kgsmith at gmail.com, 2013.
* @license This software is released under the Boost
* Software License, version 1.0.
* See LICENSE_1_0.txt or
* http://www.boost.org/LICENSE_1_0.txt
*/

#pragma once

#define TEST BOOST_AUTO_TEST_CASE
#define FTST BOOST_FIXTURE_TEST_CASE
#define EQ BOOST_REQUIRE_EQUAL
#define NE BOOST_REQUIRE_NE
#define THROW BOOST_REQUIRE_THROW
#define NO_THROW BOOST_REQUIRE_NO_THROW

#include <iostream>
#include <string>
#include <vector>
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include "stream_saver_t.hpp"

inline std::string vecstr(const std::vector<char>& rhs)
{
std::string s(rhs.begin(), rhs.end());
return s;
}

inline std::vector<char> vecstr(const std::string& rhs)
{
std::vector<char> v(rhs.begin(), rhs.end());
return v;
}

inline std::ostream& operator<<(std::ostream& os, const std::nullptr_t& rhs)
{
os << "nullptr";
return os;
}

inline std::ostream& operator<<(std::ostream& os, const std::vector<char>& rhs)
{
stream_saver_t saver(os);

os
<< "["
<< rhs.size()
<< "]"
<< std::hex << "{";
for (char byte : rhs)
{
os << "0x" << uint32_t(uint8_t(byte)) << ",";
}
os << "}";

return os;
}
54 changes: 54 additions & 0 deletions markov_refactor/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This software is released under the Boost Software License, version 1.0.
# See LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
# Copyright Ken Smith kgsmith at gmail dot com, 2013.

# User configurable portion.
prefix := /usr/local
cpus := 4
prog := $(notdir $(CURDIR))

# Implementation
MAKEFLAGS := j$(cpus)
g := g++ -flto -g -std=c++11 -Wall -Werror -pedantic
c := $(g) -c -MMD
l := $(g)
s := $(wildcard *.cpp)
o := $(addprefix .,$(patsubst %.cpp,%.o,$(s)))
d := $(o:o=d)
p := $(filter-out .test-%.o,$(o))
t := $(patsubst %.o,%,$(filter .test-%.o,$(o)))

.PRECIOUS\
:$(t)\
$(o)

$(prog)\
:$(p) $(addsuffix .passed,$(t))\
#;$(l) -o $@ $(p) -lluabind

.%.o\
:%.cpp $(MAKEFILE_LIST)\
;$(c) -o $@ $<

.test-%.passed\
:.test-%\
;./$< --random\
&& touch $@

.test-%\
:.test-%.o\
;$(l) -o $@ $< -lboost_unit_test_framework

.PHONY\
:clean\
install

install\
:$(prog)\
;cp $(prog) $(prefix)/bin

clean\
:\
;rm -Rf $(prog) $(t) .*.o .*.d .*.passed html latex

-include $(d)
Loading

0 comments on commit d349c1a

Please sign in to comment.