Automatic software test data generation is the process of generating a set of test cases for a given program which can achieve a high code coverage. Genetic algorithms (GAs) and particle swarm optimisation (PSO) can automatically evolve a set of test data, but the traditional representation in GAs and PSO produces solutions with a single set of data cases, which may not achieve good performance on programs with many complex conditions. This paper proposes a multi-vector representation in GAs and PSO, which can generate multiple sets of data cases in a single run, to generate test data for complex test programs. Experiments have been conducted to examine and compare the performance of GAs and PSO on six commonly used benchmark test programs and three newly developed programs with a relatively large number of complex conditions. The experimental results show that the proposed multi-vector representation can improve the performance of GAs and PSO on all the nine tested programs, achieving the optimal 100% code coverage on the relatively easy programs. PSO outperforms GAs in terms of both the code coverage and the computational efficiency, especially on the hard programs.