TEST_F(TestConsoleSystem, promptCmdSet) {
  sgConsole.setCwd(dir0);
  sgConsole.getUi()->setCmdLine("set paramString");
  sgConsole.prompt();
  EXPECT_EQ("set paramString", getCmdLine());
  sgConsole.getUi()->setCmdLine("set paramString ");
  sgConsole.prompt();

  EXPECT_EQ("set paramString ", getCmdLine());
  EXPECT_EQ("one  three  two  \n", getLastOutput());
  sgConsole.getUi()->setCmdLine("set paramString o");
  sgConsole.prompt();
  EXPECT_EQ("set paramString one", getCmdLine());
  sgConsole.getUi()->setCmdLine("set paramString tw");
  sgConsole.prompt();
  EXPECT_EQ("set paramString two", getCmdLine());
  sgConsole.getUi()->setCmdLine("set " + d + "di");
  sgConsole.prompt();
  EXPECT_EQ("set " + d + "dir0", getCmdLine());
  sgConsole.getUi()->setCmdLine("set " + pathDir0_0 + " paramString tw");
  sgConsole.prompt();
  EXPECT_EQ("set " + pathDir0_0 + " paramString two", getCmdLine());
  sgConsole.getUi()->setCmdLine("set " + pathDir0_0_0 + " paramBool f");
  sgConsole.prompt();
  EXPECT_EQ("set " + pathDir0_0_0 + " paramBool false", getCmdLine());
}
Example #2
0
float NeuralNetwork::trainNetwork(const std::vector<float> &input, const std::vector<float> &desired_output) {
	if (first_layer == nullptr) {
		return 0.0f;
	}
	processInput(input);
	std::vector<float> out = getLastOutput();
	std::vector<float> dif(out.size());
	float dist = 0.0f;
	for (unsigned int i = 0; i < out.size(); i++) {
		dif[i] = desired_output[i] - out[i];
		dist += dif[i]*dif[i];
	}
	last_layer->processAndForwardError(dif);
	return sqrt(dist);
}