<commit_before>package dev

import (
	"testing"

	"github.com/relab/gorums/ordering"
)

var (
	testMsg = &gorumsMessage{
		metadata: &ordering.Metadata{MessageID: 1, MethodID: 2},
		message:  &Request{Value: "foo bar"},
	}
	codec = newGorumsCodec()
)

func TestMarshalGorumsMessage(t *testing.T) {
	_, err := codec.gorumsMarshal(testMsg)
	if err != nil {
		t.Error(err)
	}
}

func TestUnmarshalGorumsMessage(t *testing.T) {
	buf, err := codec.gorumsMarshal(testMsg)
	if err != nil {
		t.Error(err)
	}

	msg := &gorumsMessage{metadata: &ordering.Metadata{}, message: &Request{}}
	err = codec.gorumsUnmarshal(buf, msg)
	if err != nil {
		t.Error(err)
	}

	if msg.metadata.MessageID != 1 || msg.metadata.MethodID != 2 || msg.message.(*Request).Value != "foo bar" {
		t.Errorf("Failed to unmarshal message correctly.")
	}
}<commit_msg>added TestMarshalUnsupportedType and use public api<commit_after>package dev

import (
	"testing"
	"time"

	"github.com/relab/gorums/ordering"
)

var (
	testMsg = &gorumsMessage{
		metadata: &ordering.Metadata{MessageID: 1, MethodID: 2},
		message:  &Request{Value: "foo bar"},
	}
	codec = newGorumsCodec()
)

func TestMarshalGorumsMessage(t *testing.T) {
	_, err := codec.Marshal(testMsg)
	if err != nil {
		t.Error(err)
	}
}

func TestUnmarshalGorumsMessage(t *testing.T) {
	buf, err := codec.Marshal(testMsg)
	if err != nil {
		t.Error(err)
	}

	msg := &gorumsMessage{metadata: &ordering.Metadata{}, message: &Request{}}
	err = codec.Unmarshal(buf, msg)
	if err != nil {
		t.Error(err)
	}

	if msg.metadata.MessageID != 1 || msg.metadata.MethodID != 2 || msg.message.(*Request).Value != "foo bar" {
		t.Errorf("Failed to unmarshal message correctly.")
	}
}

func TestMarshalUnsupportedType(t *testing.T) {
	now := time.Now()
	_, err := codec.Marshal(now)
	if err == nil {
		t.Error("Expected error from gorumsEncoder since marshalling unsupported type")
	}
}
{'fraction_non_alphanumeric': 0.15644820295983086, 'fraction_numerical': 0.004228329809725159, 'mean_word_length': 4.362606232294618, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4657872', 'n_tokens_mistral': 735, 'n_tokens_neox': 688, 'n_words': 150}