summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/tests/create_test.rb
blob: ba6e0c2e51f5c1f2a3174ebfb3d9cf58525fd692 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/ruby
#
#    Copyright (c) 2005      by Duncan Mac-Vicar       <duncan@kde.org>
#
#    Kopete    (c) 2002-2005 by the Kopete developers  <kopete-devel@kde.org>
#
#    *************************************************************************
#    *                                                                       *
#    * This program is free software; you can redistribute it and/or modify  *
#    * it under the terms of the GNU General Public License as published by  *
#    * the Free Software Foundation; either version 2 of the License, or     *
#    * (at your option) any later version.                                   *
#    *                                                                       *
#    *************************************************************************

className = ARGV[0]

if className.nil?
	puts "Need a class name"
	exit
end

puts "Creating test for class #{className}"

hBase = "template_test.h"
cppBase = "template_test.cpp"

fileH = File.new(hBase).read
fileCpp = File.new(cppBase).read

fileH.gsub!(/TEMPLATE/, className.upcase.gsub(/::/,""))
fileH.gsub!(/Template/, className.gsub(/::/,""))
fileH.gsub!(/some requirement/, className + " class.")

fileCpp.gsub!(/TEMPLATE/, className.upcase.gsub(/::/,""))
fileCpp.gsub!(/template/, className.downcase.gsub(/::/,""))
fileCpp.gsub!(/Template/, className.gsub(/::/,""))
fileCpp.gsub!(/some requirement/, className + " class.")

makefileAm = "kunittest_template_test_la_SOURCES = template_test.cpp\nkunittest_template_test_la_LIBADD = -lkunittest ../tqmock/libkopete_tqmock.la\nkunittest_template_test_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)\n"
makefileAm.gsub!(/template/, className.downcase.gsub(/::/,""))

hNew = hBase.gsub(/template/, className.downcase.gsub(/::/,""))
cppNew = cppBase.gsub(/template/, className.downcase.gsub(/::/,""))

hOut = File.new(hNew, "w")
cppOut = File.new(cppNew, "w")

hOut.write(fileH)
cppOut.write(fileCpp)

puts "#{hNew} and #{cppNew} writen."

puts "Please add the following to Makefile.am:"
puts makefileAm