That depends on a tactic.
If you just have two swarms of different meatbags charging at each other, then the one with more speed and durability wins. You didn't provide any numbers, but assuming 1-1 ratio, even normal horses should be able to defeat the humans, longswords or not.
Horses are big, powerful beasts:
https://www.youtube.com/watch?v=-srzT2olJ2Q
https://www.youtube.com/watch?v=J95LsygVMaQ
They can kick, bite, or just run you over.
And when it's charging, and you stab it with your tiny long sword it'll have enough momentum to run you over, most likely killing you and the guy behind you.
And now let's add a horn to that scenario. With them, you may never even have a chance to use that sword - you'll be a dead long before the beast is in range.
Now, there are ways to defeat them, even with such weak weapons like swords.
One of them is preparing the battlefield to your advantage (for example by digging trenches). Given the title I assume that we are talking about an open field, so we can cross out this option.
Second tactic would be scaring the beasts off with noises they don't like, fire, commotion, etc. I don't know if it's possible in your setting.
Third way I can think about is simply outnumbering them in overwhelming odds - but expect HEAVY losses, because it will take lives of several men to kill one horse (and even more with a unicorn).
But if your question was about only about the first impact in an open field, then my answer is that there will be no line of infantry after the two forces meet.
[EDIT]
To address a good point made by @Monica Cellio in a comment:
I'd say that killing a horse (or a unicorn) with a long sword is a no small task.
For starters, let's assume, that we have one man trying to kill a unicorn, which cannot fight back. The only restriction is that he has too attack beast's front. What are his options?
He can try to attack the head. Good luck with that. Here is how a typical horse looks from the inside:
http://www.infovisual.info/02/072_en.html
You'll notice, that it's pretty much nothing but a skull. You may have some luck with a hammer or a pick, but a long sword is most likely the worst weapon to use for such attack - it will scratch the skin and bounce off the bone. A horn provides even more protection.
Next on the line is the chest. In this case it is a matter of luck, but even if you somehow manage to stab right through the heart, it will take a couple of seconds before the brain runs out of oxygen, so even with best of luck, you have no chance of an instant kill.
But that is not a likely scenario. In most cases the horse would look like this:
Please notice, that there is not much of the chest visible to hit, mostly it's protected by the head.
If you get the chance to stab the beast, you'll most likely hit hard and dense muscle tissue - not exactly an armour, but you need some effort to go through it to juicy internal organs.
I'd say that your best chest option is slash it several times and wait till it bleeds out.
Last but not least - legs. Hard bones, surrounded by muscles designed to move a heavy body with a great speed. This, however, is your best option - you won't kill the beast, but if you damage the muscles enough, you'll incapacitate it for good. Long sword is best used for slashing, and that's exactly the kind of damage you need for this task.
And now apply the story scenario: the unicorns are charging, the attack, fight back, there is a lot of kicking, screaming, nobody really knows what's going on. Complete, utter chaos. Some soldiers will get lucky and damage the legs, some unicorns may bleed out afterwards, but I don't think that swords will be much of a use in this case.
Not enough time to use them properly, not enough space and the targets fight back to well.
So to rephrase the original question:
Charging unicorns WOULD survive an impact with a line of infantry.